2015-07-02 15:28:02 |
Stefano Verzegnassi |
description |
Currently, if a user tries to open a document from external apps (e.g. filemanager-app), a new copy will be created in $HOME/Documents.
There are anyway some cases that we don't want this happens:
1) When opening a document from $HOME/Documents using filemanager-app.
A new copy of the file is created in the same folder.
2) When opening a document from any path, and a copy of the same file already exists in $HOME/Documents.
As Riccardo Padovani (@rpadovani) pointed out during a MP review[1] of docviewer-app, we may want to calculate the MD5 checksum for the imported file, and check if there's already a file in the destination folder, with the same file name and the same checksum.
[1]: https://code.launchpad.net/~verzegnassi-stefano/ubuntu-docviewer-app/document-hub2/+merge/251166 |
Currently, if a user tries to open a document from external apps (e.g. filemanager-app), a new copy will be created in $HOME/Documents.
There are anyway some cases that we don't want this happens:
1) When opening a document from $HOME/Documents using filemanager-app.
A new copy of the file is created in the same folder.
2) When opening a document from any path, and a copy of the same file already exists in $HOME/Documents.
In order to achieve this without using too much resources on mobile devices, we should check three conditions:
1) A file with the same name already exists in $HOME/Documents.
2) If the check at 1) returns true, we should check if the two files have the same size.
3) IIRC while importing a document through content-hub, the lastModified() date-time provided by QFileInfo[1] is preserved (but created() time changes). If that's true, we should check also for this parameter.
If all the used conditions are true, content-hub is trying to import a document which was already imported in the past: the app should finalize the active transfer without copying the file, but still notify the user that the transfer has been successfully completed.
[1] http://doc.qt.io/qt-5/qfileinfo.html#lastModified |
|