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

Display versions for a file and allow any version to be restored #4805

Closed
wants to merge 9 commits into from
Closed

Display versions for a file and allow any version to be restored #4805

wants to merge 9 commits into from

Conversation

seantempleton
Copy link
Contributor

On the restore page a file now has a dropdown arrow next to it. Upon expanding it the versions of that file will be retrieved and displayed.
Upon displaying the list of versions the first time, if the file was already selected then the default version selected will be the one that belongs to the currently selected backup.
The user can select any version, or versions, hit restore, and the selected versions will be restored. If one version is selected the restored file will have the original filename. If multiple versions are selected each filename will have the modified time appended to the name.

Closes #72

…odes

The functionality should be the exact same after these changes.
Rather than building a dictionary object from the ngSelected array all the time, use a dictionary from the beginning.
The dictionary will be updated when the check state of a node changes, which will then trigger the partial map to be updated. The partial map only needs to be updated when the dictionary changes rather than also building it all the time.
Made a general cleanup pass of the file.
Remove unused and newly unneeded functions, renamed some variables.
If there are two or more nodes under the root node, select all of the nodes then deselect the root node, one or more of the nodes under the root node remains selected.
Fixed by removing all selected nodes under the root from the selected dictionary when selecting a node. The check is propogated all the way up to the root node and if all of its children are selected, they can be removed from the dictionary.

Also, prevented the full path of a file from being placed in the partial map as there is nothing beneath a file.
updateNodesFromMap will now only update the nodes (and their children) that are passed in. Or if none are passed in then the entire tree is updated.
When expanding a file, a request is made to the backend for all the versions of that file. They are then shown in descending order, most recent at the top.
Versions are handled specially. If selected they are always put in ngSelected. Exception to this is if the default version, the latest version, is the only version selected.
In that case the file itself is put in ngSelected because that version of the file will be restored from the chosen backup.

Added logic changes for the above plus edge cases of e.g.
1. Check a file, the first version is automatically checked and the file is added to ngSelected.
2. Check the first version, the file is automatically checked and added to ngSelected.
3. Check the second version, that version is added to ngSelected and the file is checked.
4. The file already has been selected, meaning the default version is selected, and then another version is checked. The file is removed from ngSelected, the two versions are added to ngSelected.
5. Propagation logic when deselecting versions or files.
Change file picker to use the version that is in the selected backup as the default version instead of using the first version as the default.
The modified time of the file is appended to the restored filename when multiple versions of a file are being restored
If the version of a file that is selected to be restored is the version of the file that is in the chosen backup, then no special logic needs to be performed. It is a normal restore.
If the selected version is not in the chosen backup, the fileId is passed to the backend and used to restore that specific version of the file.

When any version is selected that is not the default version (the version in the chosen backup), then ALL selected versions for that file have the fileId sent to the backend. Additionally, if
more than one version is selected, and one of those is the default version, all fileIds are sent to the backend and the file from the chosen backup is "ignored".
The files from the backup are put into a temp table and since specific versions are going to be restored, the file with versions selected must be removed from that table so the specific versions of
the file can be put in the table and have the modified time be part of the filenames.
… user specifies to not overwrite existing files

Two scenarios
1) Restore a versioned file with the regular file name. Append the last modified time to the filename.
2) A versioned file is already being restored with the last modified time in the filename. Make sure to not append the time again and let the existing logic choose a new name.
Change x-tree-icon class for a file from x-tree-icon-leaf to x-tree-icon-file.
Change x-tree-icon-fileversion back to leaf as multiple things depend on leaf and it is hard to track them all down.
Set a file node to not be expanded when searching.
… unit tests

Fixed existing unit tests by:
m_filters was null because the unit tests did not call a constructor on FilterExpression which set it. Create a new List on construction so it is not null.
If m_filters was empty, OnlyContainsFilterType() would return true. Added a check that there were items in the list first.
A call to Parameters.Clear() was accidentally removed after ExecuteScalarInt64() was called. ExecuteScalarInt64() clears parameters, adds any if needed, but does not clear its own parameters.
Use the proper OS directory separator before the &fileid= indicator from the frontend of what file id to restore.
@xh542428798
Copy link

I really like this feature; is it would be in next version?

@xh542428798
Copy link

Hi, Sir, have you considered to display the modified time of files in different versions. Most time I just want to restore a certain version of a file according to the file modified time, but now I didn't find any way to see the modified time of a file.

@duplicatibot
Copy link

This pull request has been mentioned on Duplicati. There might be relevant details there:

https://forum.duplicati.com/t/feature-request/14987/2

@duplicatibot
Copy link

This pull request has been mentioned on Duplicati. There might be relevant details there:

https://forum.duplicati.com/t/restoration-network-speed-limited-to-100mbits-s/15206/5

@duplicatibot
Copy link

This pull request has been mentioned on Duplicati. There might be relevant details there:

https://forum.duplicati.com/t/my-story-backup-db-broke-when-i-needed-it/15741/12

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.

Show all versions of a file in the recovery tree [$280]
3 participants