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

Prevent downgrade of vfs folder #9119

Merged
merged 2 commits into from
Oct 6, 2021
Merged

Prevent downgrade of vfs folder #9119

merged 2 commits into from
Oct 6, 2021

Conversation

TheOneRing
Copy link
Contributor

@TheOneRing TheOneRing commented Oct 5, 2021

image

@TheOneRing TheOneRing requested a review from a team October 5, 2021 09:47
@TheOneRing TheOneRing added this to the 2.9.1 milestone Oct 5, 2021
@TheOneRing TheOneRing linked an issue Oct 5, 2021 that may be closed by this pull request
@TheOneRing TheOneRing force-pushed the work/prevent_downgrade branch from 2a2a329 to a8a8d18 Compare October 5, 2021 09:50
@@ -1299,9 +1310,9 @@ void FolderDefinition::save(QSettings &settings, const FolderDefinition &folder)

// Ensure new vfs modes won't be attempted by older clients
if (folder.virtualFilesMode == Vfs::WindowsCfApi) {
settings.setValue(QLatin1String(versionC), 3);
settings.setValue(versionC(), 4);
Copy link
Collaborator

Choose a reason for hiding this comment

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

shouldn't this call maxSettingsVersion()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm as you can see two lines later it doesn't always need to be the max version.
But I'll extract the two versions.

* [Accounts]
* 0\version=1
*/
auto versionC()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Isn't this a duplicate of the one in folder.cpp?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Both are version but in different section that are evaluated independently.
But yes...
However refactoring the settings stuff is stuff for a major release...

if (foldersVersion <= maxFoldersVersion) {
const auto &childGroups = settings->childGroups();
for (const auto &folderAlias : childGroups) {
settings->beginGroup(folderAlias);
const int folderVersion = settings->value(QLatin1String(versionC), 1).toInt();
const int folderVersion = settings->value(versionC(), 1).toInt();
Copy link
Collaborator

Choose a reason for hiding this comment

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

1 is another magic number. Can you make constants somewhere in 1 place (in a header file?) and add some comments to them? I've now seen 1, 2, and 4. Oh, and there was a 3, but that's now "old"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For some reason someone decided to start to count with 1, that's why we default to 1 if no version at all is set.

@TheOneRing TheOneRing force-pushed the work/prevent_downgrade branch from a8a8d18 to 5d9461f Compare October 6, 2021 08:41
@TheOneRing TheOneRing requested review from erikjv and a team October 6, 2021 08:42
@TheOneRing TheOneRing merged commit 2a06b59 into 2.9.1 Oct 6, 2021
@delete-merged-branch delete-merged-branch bot deleted the work/prevent_downgrade branch October 6, 2021 09:17
@sonarqubecloud
Copy link

sonarqubecloud bot commented Oct 6, 2021

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@gabi18 gabi18 mentioned this pull request Oct 11, 2021
46 tasks
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.

Downgrade of 2.9.1 to 2.9.0 triggers deletion WinVFS
2 participants