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

Inconsistency in camera upload sync #301

Closed
troed opened this issue Mar 16, 2015 · 6 comments
Closed

Inconsistency in camera upload sync #301

troed opened this issue Mar 16, 2015 · 6 comments
Assignees

Comments

@troed
Copy link

troed commented Mar 16, 2015

The following is valid for a Sony Xperia Z3 Compact. I don't know if it's valid for all Androids.

  1. Take picture - name might be DSC_0297.JPG
  2. Let picture sync using seadroid's automatic camera upload feature
  3. Delete picture (on mobile & in libraries)
  4. Take new picture - name will again be DSC_0297.JPG
  5. The new picture will never sync

This is unexpected behavior and might cause users to believe their photos are backed up when they aren't. If filename are used to know what to sync then maybe hashes of content might be needed instead.

@shoeper
Copy link
Collaborator

shoeper commented Mar 16, 2015

As a temporary fix you could check if you can enable timestamps for files names in your camera settings.

Technically there is a problem with the FileObserver (honestly I'm not 100% sure if one is used - if not it imho should be used) or the methods handling the events.
It could also be that the FileObserver is not running all time.

@Logan676
Copy link
Contributor

Take new picture - name will again be DSC_0297.JPG

This is the reason why it doest sync any more, because Camera Upload Service marked the photo as synced via its name into local database. To fix that, you can go to OS Apps manager --> Seafile --> App Info --> Clear cache` (to remote the database).

@shoeper
Copy link
Collaborator

shoeper commented Mar 16, 2015

Seafile could use FileObserver to also delete files when they are deleted and upload files on modify and on create. In addition if that shouldn't be done seafile could honor last modification time / creation time.

@troed
Copy link
Author

troed commented Mar 17, 2015

@Logan676 It's clear why the issue happens - but it's unexpected behavior and will cause loss of trust. It's common for users of mobile phones to delete camera photos - and if those photos had been automatically backed up using Seadroid the new photos taken (filling up the holes in the naming scheme) will never be backed up/uploaded. Since the user hasn't taken an action where they could expect such behavior there should be no need for them to perform manual workarounds.

Checking vs last modification/creation time in addition to the name in the database entry would work fine as a solution.

@Logan676 Logan676 self-assigned this Mar 17, 2015
@Logan676
Copy link
Contributor

Thanks for your comment, will add this feature soon.

@tomchiverton
Copy link

Add for the next release ?

forouher added a commit to forouher/seadroid that referenced this issue Nov 15, 2015
This patch reworks most of the camera upload. It contains two important
changes:

(1) The old code implemented camera upload as a service. While that worked,
it proved somewhat problematic. Services can be killed by Android, and the
service had to be started by an Activity.

Android provides an API for implementing data syncing:
https://developer.android.com/training/sync-adapters/index.html

This API provides a number of advantages compared to a self-implemented
service. Among them are:

* Less code
* Automatic error recovery (e.g. retry on network errors)
* Periodic synchronisation (e.g. every 24h)
* Better visibility to the user (via Android Settings->Accounts)

(2) The old camera media sync algortihm tried to upload media via two ways:

a) when a new photo was added to the MediaStore, that photo was uploaded. But
*only* if the data plan allowed it.
b) when the user interacts with Seadroid, the service uploaded all photos
not yet uploaded. It did that by scanning certain hard-coded directories
on the externalStorage  and looking for new media files.

Important changes added by this patch:

- This new design builds soly on the MediaStore. The MediaStore contains
all images/videos on the phone. Therefore it should not be necessary to
scan (or even be aware of) where the photos are actually stored.

- The MediaStore has a column where it records the "DATA_ADDED" for every
media file. We can use that to sort and filter for new newly added media
files. This eases up the syncing mechanism considerably.

- Allowing to sync to sub directories in a repository.

- There is still a service necessary to monitor MediaStore activity. However
even without that service, Android will perform a sync about every 24h.
Also that service is now autostarted on System boot and on Seadroid
apk upgrades.

- Finally merging with existing files on the server was also improved by
skipping files that are already present on the server (it compares the file
size and will still upload if the sizes differ. That's probably the best
one can do with the current API2).

Overall, this patch should adresses the following issues:

issue haiwen#277 (Camera upload function dumps all subdir files into single dir)
issue haiwen#301 (Inconsistency in camera upload sync)
issue haiwen#311 (second suggestion: target repo sub directories)
issue haiwen#336 (file duplication when doing a full resync)
issue haiwen#375 (Picture upload not acting as service?)
issue haiwen#423 (Pictures never upload) [maybe. not sure what's going on there]

Useful links:
https://developer.android.com/training/sync-adapters/creating-sync-adapter.html
http://blog.udinic.com/2013/07/24/write-your-own-android-sync-adapter/
forouher added a commit to forouher/seadroid that referenced this issue Nov 23, 2015
This patch reworks most of the camera upload. It contains two important
changes:

(1) The old code implemented camera upload as a service. While that worked,
it proved somewhat problematic. Services can be killed by Android, and the
service had to be started by an Activity.

Android provides an API for implementing data syncing:
https://developer.android.com/training/sync-adapters/index.html

This API provides a number of advantages compared to a self-implemented
service. Among them are:

* Less code
* Automatic error recovery (e.g. retry on network errors)
* Periodic synchronisation (e.g. every 24h)
* Better visibility to the user (via Android Settings->Accounts)

(2) The old camera media sync algortihm tried to upload media via two ways:

a) when a new photo was added to the MediaStore, that photo was uploaded. But
*only* if the data plan allowed it.
b) when the user interacts with Seadroid, the service uploaded all photos
not yet uploaded. It did that by scanning certain hard-coded directories
on the externalStorage  and looking for new media files.

Important changes added by this patch:

- This new design builds soly on the MediaStore. The MediaStore contains
all images/videos on the phone. Therefore it should not be necessary to
scan (or even be aware of) where the photos are actually stored.

- The MediaStore has a column where it records the "DATA_ADDED" for every
media file. We can use that to sort and filter for new newly added media
files. This eases up the syncing mechanism considerably.

- Allowing to sync to sub directories in a repository.

- There is still a service necessary to monitor MediaStore activity. However
even without that service, Android will perform a sync about every 24h.
Also that service is now autostarted on System boot and on Seadroid
apk upgrades.

- Finally merging with existing files on the server was also improved by
skipping files that are already present on the server (it compares the file
size and will still upload if the sizes differ. That's probably the best
one can do with the current API2).

Overall, this patch should adresses the following issues:

issue haiwen#277 (Camera upload function dumps all subdir files into single dir)
issue haiwen#301 (Inconsistency in camera upload sync)
issue haiwen#311 (second suggestion: target repo sub directories)
issue haiwen#336 (file duplication when doing a full resync)
issue haiwen#375 (Picture upload not acting as service?)
issue haiwen#423 (Pictures never upload) [maybe. not sure what's going on there]

Useful links:
https://developer.android.com/training/sync-adapters/creating-sync-adapter.html
http://blog.udinic.com/2013/07/24/write-your-own-android-sync-adapter/
forouher added a commit to forouher/seadroid that referenced this issue Jan 5, 2016
This patch reworks most of the camera upload. It contains two important
changes:

(1) The old code implemented camera upload as a service. While that worked,
it proved somewhat problematic. Services can be killed by Android, and the
service had to be started by an Activity.

Android provides an API for implementing data syncing:
https://developer.android.com/training/sync-adapters/index.html

This API provides a number of advantages compared to a self-implemented
service. Among them are:

* Less code
* Automatic error recovery (e.g. retry on network errors)
* Periodic synchronisation (e.g. every 24h)
* Better visibility to the user (via Android Settings->Accounts)

(2) The old camera media sync algortihm tried to upload media via two ways:

a) when a new photo was added to the MediaStore, that photo was uploaded. But
*only* if the data plan allowed it.
b) when the user interacts with Seadroid, the service uploaded all photos
not yet uploaded. It did that by scanning certain hard-coded directories
on the externalStorage  and looking for new media files.

Important changes added by this patch:

- This new design builds soly on the MediaStore. The MediaStore contains
all images/videos on the phone. Therefore it should not be necessary to
scan (or even be aware of) where the photos are actually stored.

- The MediaStore has a column where it records the "DATA_ADDED" for every
media file. We can use that to sort and filter for new newly added media
files. This eases up the syncing mechanism considerably.

- Allowing to sync to sub directories in a repository.

- There is still a service necessary to monitor MediaStore activity. However
even without that service, Android will perform a sync about every 24h.
Also that service is now autostarted on System boot and on Seadroid
apk upgrades.

- Finally merging with existing files on the server was also improved by
skipping files that are already present on the server (it compares the file
size and will still upload if the sizes differ. That's probably the best
one can do with the current API2).

Overall, this patch should adresses the following issues:

issue haiwen#277 (Camera upload function dumps all subdir files into single dir)
issue haiwen#301 (Inconsistency in camera upload sync)
issue haiwen#311 (second suggestion: target repo sub directories)
issue haiwen#336 (file duplication when doing a full resync)
issue haiwen#375 (Picture upload not acting as service?)
issue haiwen#423 (Pictures never upload) [maybe. not sure what's going on there]

Useful links:
https://developer.android.com/training/sync-adapters/creating-sync-adapter.html
http://blog.udinic.com/2013/07/24/write-your-own-android-sync-adapter/
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

No branches or pull requests

4 participants