Skip to content

Conversation

@jianba
Copy link

@jianba jianba commented Dec 27, 2025

No description provided.

@jianba
Copy link
Author

jianba commented Dec 29, 2025

@abdularis bro look look

@abdularis abdularis requested a review from Copilot December 29, 2025 09:50
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a bug in the file transfer sender by normalizing folder path separators based on the receiver's operating system. The change ensures that folder paths use backslashes for Windows receivers and forward slashes for Linux/macOS receivers.

  • Adds OS-specific folder path separator normalization before sending file headers

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +160 to +165

if (mReceiverDev.getOSName() == "Windows") {
mFolderName.replace("/", "\\");
} else {
// Linux & macOS
mFolderName.replace("\\", "/");
Copy link

Copilot AI Dec 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic assumes only three operating systems (Windows, Linux, macOS). Consider using a more robust approach that explicitly handles all expected OS values or adds a default case. Additionally, using Qt's QDir::toNativeSeparators() and QDir::fromNativeSeparators() would be more maintainable than manual string replacement.

Suggested change
if (mReceiverDev.getOSName() == "Windows") {
mFolderName.replace("/", "\\");
} else {
// Linux & macOS
mFolderName.replace("\\", "/");
// Normalize folder name to use forward slashes first.
QString normalizedFolder = QDir::fromNativeSeparators(mFolderName);
const QString osName = mReceiverDev.getOSName();
if (osName.compare("Windows", Qt::CaseInsensitive) == 0) {
// Receiver is Windows: use backslashes.
mFolderName = normalizedFolder;
mFolderName.replace("/", "\\");
} else if (osName.compare("Linux", Qt::CaseInsensitive) == 0
|| osName.compare("macOS", Qt::CaseInsensitive) == 0) {
// Receiver is Linux or macOS: keep normalized forward slashes.
mFolderName = normalizedFolder;
} else {
// Fallback for other/unknown OS names: use normalized forward slashes.
mFolderName = normalizedFolder;

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant