Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows: Additional write permissions check #5510

Closed
wants to merge 8 commits into from
Closed
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/gui/folderman.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*

Check notice on line 1 in src/gui/folderman.cpp

View workflow job for this annotation

GitHub Actions / build

Run clang-format on src/gui/folderman.cpp

File src/gui/folderman.cpp does not conform to Custom style guidelines. (lines 1720)
* Copyright (C) by Klaas Freitag <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -1701,9 +1701,29 @@
return FolderMan::tr("The selected path is not a folder!");
}

#ifdef Q_OS_WIN
if (!selFile.isWritable()) {
// isWritable() doesn't cover all NTFS permissions
// Try write
const auto testPath = selFile.dir().filePath("nextcloud-write-test-file.txt");
const auto fp = fopen(testPath.c_str(), "w");
Alkl58 marked this conversation as resolved.
Show resolved Hide resolved
if (!fp) {
return FolderMan::tr("You have no permission to write to the selected folder!");
}
fclose(fp);

// Try delete
const auto rc = remove(testPath.c_str());
Alkl58 marked this conversation as resolved.
Show resolved Hide resolved
if (rc) {
return FolderMan::tr("You have no permission to write to the selected folder!");
}
}
#else
if (!selFile.isWritable()) {
return FolderMan::tr("You have no permission to write to the selected folder!");
}
#endif

return QString();
}

Expand Down
Loading