Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat(versioner): add 'Archive Deleted Only' option to trashcan versioner (fixes #6164)#10111

Open
tejas-rkd wants to merge 3 commits intosyncthing:mainfrom
tejas-rkd:feat-6164
Open

feat(versioner): add 'Archive Deleted Only' option to trashcan versioner (fixes #6164)#10111
tejas-rkd wants to merge 3 commits intosyncthing:mainfrom
tejas-rkd:feat-6164

Conversation

@tejas-rkd
Copy link

@tejas-rkd tejas-rkd commented May 16, 2025

Purpose

The current trash can versioning system creates a backup of files both when they are deleted and when they are modified. For many users, the primary concern is protecting against accidental deletions, not needing a full history of file changes. A more lightweight option that only versions deleted files, would address the most painful data loss scenarios while using significantly less disk space than full versioning. (fixes #6164)

Solution

Add a new "Archive Deleted Only" option to the Trash Can versioning system. When enabled, this option makes the versioner only archive files that are deleted, skipping versioning for modifications. This provides protection against the most common data loss scenarios without filling up storage with versions of every modified file.

This is implemented through a new interface ArchiverForDeletedOnly which exposes an ArchiveDeletedOnly() method to check this configuration. The folder-sync code has been updated to check this setting and skip archiving for file modifications when enabled.

Testing

  1. Archive Deleted Only checkbox value persistence to backend.
  2. Modify, Rename and Delete file for No Versioner.
  3. Modify, Rename and Delete file for Trashcan Versioner with Archive Deleted Only selected.
  4. Modify, Rename and Delete file for Trashcan Versioner with Archive Deleted Only un-selected.
  5. For all above permutations, I checked it's corresponding UI impact as well.

Screenshots

Home Page
Edit Modal

Documentation

syncthing/docs#930
These changes are subjected to change in this pull request.

Authorship

Your name and email will be added automatically to the AUTHORS file
based on the commit metadata.

@tejas-rkd tejas-rkd marked this pull request as draft May 16, 2025 11:06
@tejas-rkd tejas-rkd changed the title feat(#6164): add 'Archive Deleted Only' option to trashcan versioner feat(versioner): add 'Archive Deleted Only' option to trashcan versioner (fixes #6164) May 16, 2025
@tomasz1986
Copy link
Member

tomasz1986 commented May 16, 2025

Thank you for working on this! I will personally find this very useful, e.g. when dealing with virtual disk images that are huge in size and change often, making the current versioning approach not feasible and forcing to disable file versioning for the whole folder.

Just a comment, as I haven't tested the code at all yet. I don't think we actually use the word "archive" in the GUI when talking about versioning. I understand that it is present in the code, but in the GUI, we just talk about "Versions Path" and "versions being stored" there (i.e. not "archived"). Wouldn't it be better and more understandable if we stick to the current wording?

Basically, what I want to say that "archive" is a vague term, which can mean different things depending on the context.

Also, are you planning to enable this by default? If not, then I think it should be just ref #6164 instead of fixes #6164.

Copy link
Member

@acolomb acolomb left a comment

Choose a reason for hiding this comment

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

I've quickly glanced over the code changes and in general, the feature seems sensible. The extra interface for checking whether the versioner supports the flag seems a little specific and could possibly be integrated more elegantly / with broader scope. Though I can't give you a counter-proposal now, would need to invest more time understanding the relevant bits first. So let's hear an opinion on that from the other maintainers.

The change to the man page is however definitely out of place, because it is generated from the docs repo and should be adjusted there.

@tejas-rkd
Copy link
Author

Thank you for working on this! I will personally find this very useful, e.g. when dealing with virtual disk images that are huge in size and change often, making the current versioning approach not feasible and forcing to disable file versioning for the whole folder.

Glad that this change is helpful to you!

Just a comment, as I haven't tested the code at all yet. I don't think we actually use the word "archive" in the GUI when talking about versioning. I understand that it is present in the code, but in the GUI, we just talk about "Versions Path" and "versions being stored" there (i.e. not "archived"). Wouldn't it be better and more understandable if we stick to the current wording?

Basically, what I want to say that "archive" is a vague term, which can mean different things depending on the context.

I have made changes to UI code. Do you think we need similar renaming across backend changes?

Also, are you planning to enable this by default? If not, then I think it should be just ref #6164 instead of fixes #6164.

Going through #6164 discussion, I don't see a clear majority for any behavior. Let's use this PR to invigorate the dead discussion 🙈

@tejas-rkd
Copy link
Author

I've quickly glanced over the code changes and in general, the feature seems sensible. The extra interface for checking whether the versioner supports the flag seems a little specific and could possibly be integrated more elegantly / with broader scope. Though I can't give you a counter-proposal now, would need to invest more time understanding the relevant bits first. So let's hear an opinion on that from the other maintainers.

Thank you for the review. My motivation behind this was to avoid modifying the core Versioner interface and only the versioners that support this feature need to implement the interface. But I am open for suggestions.

The change to the man page is however definitely out of place, because it is generated from the docs repo and should be adjusted there.

Removed man changes as they are tracked via syncthing/docs#930

@tejas-rkd tejas-rkd marked this pull request as ready for review May 19, 2025 12:04
"Anonymous usage report format has changed. Would you like to move to the new format?": "Anonymous usage report format has changed. Would you like to move to the new format?",
"Applied to LAN": "Applied to LAN",
"Apply": "Apply",
"Version Deleted Only":"Version Deleted Only",
Copy link
Member

Choose a reason for hiding this comment

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

Did you insert this string manually? Because it sure looks like having a different white-space pattern.

The correct way to update this file is this:

go run build.go translate

Possibly after first emptying the file (just {} as content), in case you removed strings.

@rasa
Copy link
Member

rasa commented May 20, 2025

Sorry for the late feedback, but the word "archive" is used several times in
https://github.com/syncthing/docs/blob/main/users/versioning.rst
Also, the word "version", when used as a verb (it's 99% of the time a noun, according to here) describes creating a new copy of something that is then used. Whereas the verb "archive" (it's 90% of the time a noun) describes creating a copy for historical purposes. So, I would suggest we stick with "archive" when describing creating a trash can backup.

@tomasz1986
Copy link
Member

tomasz1986 commented May 20, 2025

I've now looked a bit more closely at the PR.

@rasa is right about the word "archive" already used in the Docs, I think it could also be used here, just make the wording more clear and easily understandable to the user. I'll try suggesting some fixes directly in the code in this regard.

Thank you for the review. My motivation behind this was to avoid modifying the core Versioner interface and only the versioners that support this feature need to implement the interface. But I am open for suggestions.

Is there any difficulty with applying this universally to all versioning types (except external, of course)? Simple and staggered versioning would greatly benefit from the feature as well.

Going through #6164 discussion, I don't see a clear majority for any behavior. Let's use this PR to invigorate the dead discussion 🙈

On the one hand, there are different opinions, but on the other, the issue was created by @calmh himself and requests "enabling by default" right in the title, so I think to actually "fix" the issue, the option does need to come enabled. Otherwise you can just ref #6164 instead and leave the "enabling by default" part for a later discussion 😉.

<div class="checkbox">
<label for="versioning-trashcan-archiveDeletedOnly-{{currentFolder.id}}">
<input type="checkbox" id="versioning-trashcan-archiveDeletedOnly-{{currentFolder.id}}" ng-model="currentFolder._guiVersioning.archiveDeletedOnly">
<span translate>Version Deleted Only</span>
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
<span translate>Version Deleted Only</span>
<span translate>Archive Deleted Files Only</span>

<span translate>Version Deleted Only</span>
</label>
</div>
<p class="help-block"><small translate>If selected, only deleted files will be moved to the version folder. Modified files will not be versioned.</small></p>
Copy link
Member

@tomasz1986 tomasz1986 May 20, 2025

Choose a reason for hiding this comment

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

Suggested change
<p class="help-block"><small translate>If selected, only deleted files will be moved to the version folder. Modified files will not be versioned.</small></p>
<p class="help-block" translate>If selected, only deleted files will be moved to the versions directory. Modified files will not be archived.</p>

"Versions directory" is already used in the explanation under "Cleanup Interval". I also think that the text should be normal size (as is the case with other explanatory remarks in the GUI).

<span ng-switch-when="external" tooltip data-original-title="{{folder.versioning.params.command}}" translate>External</span>
</span>
<span ng-if="folder.versioning.type != 'external'">
<span ng-if="(folder.versioning.type == 'trashcan') && (folder.versioning.params.archiveDeletedOnly === 'true')" tooltip data-original-title="{{'Version Deleted Only' | translate}}">
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
<span ng-if="(folder.versioning.type == 'trashcan') && (folder.versioning.params.archiveDeletedOnly === 'true')" tooltip data-original-title="{{'Version Deleted Only' | translate}}">
<span ng-if="(folder.versioning.type == 'trashcan') && (folder.versioning.params.archiveDeletedOnly === 'true')" tooltip data-original-title="{{'Version Deleted Files Only' | translate}}">

</span>
<span ng-if="folder.versioning.type != 'external'">
<span ng-if="(folder.versioning.type == 'trashcan') && (folder.versioning.params.archiveDeletedOnly === 'true')" tooltip data-original-title="{{'Version Deleted Only' | translate}}">
&ensp;<span class="fa fa-archive"></span>&nbsp;<span ng-if="folder.versioning.params.archiveDeletedOnly" translate>Deleted Only</span>
Copy link
Member

@tomasz1986 tomasz1986 May 20, 2025

Choose a reason for hiding this comment

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

Suggested change
&ensp;<span class="fa fa-archive"></span>&nbsp;<span ng-if="folder.versioning.params.archiveDeletedOnly" translate>Deleted Only</span>
&ensp;<span class="fa fa-ban"></span>&nbsp;<span ng-if="folder.versioning.params.archiveDeletedOnly" translate>Deleted</span>

I've tried to shorten this to just "Delete" with a different icon (suggesting that deleted files are not versioned). Ignore the previous sentence, I got things mixed up, obviously the icon should suggest that only deleted files are kept 😅.

The problem is that the current Deleted Only string is too long, possibly pushing versions path outside of the folder information (as can be seen in your own screenshot). Please feel free to experiment with different ideas if you think this isn't the best solution, but the point is to make this a single word (or maybe even just an icon with a tooltip?).

@github-actions github-actions bot added the enhancement New features or improvements of some kind, as opposed to a problem (bug) label May 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New features or improvements of some kind, as opposed to a problem (bug)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Option for trashcan versioning to affect only deleted files, enable by default

4 participants