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
Fix committed into lp:ubuntu-docviewer-app/reboot at revision None, scheduled for release in ubuntu- docviewer- app, milestone Unknown