juruen / rmapi

Go app that allows you to access your reMarkable tablet files through the Cloud API
GNU Affero General Public License v3.0
976 stars 106 forks source link

`stat` or `get` different files with the same `VissibleName` #209

Open hugobuddel opened 3 years ago

hugobuddel commented 3 years ago

Is it possible to stat or get different files that share the same VissibleName?

I had some problems with sending files from my Android phone to my reMarkable 1 through the cloud. Every time I opened the app, it would send the same files again (and then often crash). So I ended up with several files with the same name. (I solved that issue by cleaning the cache of the app.)

I can see the duplicate files with ls (excluding irrelevant files):

$ ~/go/bin/rmapi 
ReMarkable Cloud API Shell
[/]>ls
...
[f]     Cryptic.20210300.New7Wonders_Hunt
...
[f]     Cryptic.20210300.New7Wonders_Hunt
...
[f]     Cryptic.20210300.New7Wonders_Hunt
...

However, when I stat one, it selects an arbitrary one:

[/]>stat Cryptic.20210300.New7Wonders_Hunt
{
  "ID": "9bc2b5df-839d-4a29-b374-df3d752024c3",
  "Version": 1,
  "Message": "",
  "Success": true,
  "BlobURLGet": "",
  "BlobURLGetExpires": "0001-01-01T00:00:00Z",
  "ModifiedClient": "2021-04-03T07:45:37.124124Z",
  "Type": "DocumentType",
  "VissibleName": "Cryptic.20210300.New7Wonders_Hunt",
  "CurrentPage": 0,
  "Bookmarked": false,
  "Parent": ""
}
[/]>stat Cryptic.20210300.New7Wonders_Hunt
{
  "ID": "d7016293-153b-4cc4-8dcd-98ae7585050f",
  "Version": 1,
  "Message": "",
  "Success": true,
  "BlobURLGet": "",
  "BlobURLGetExpires": "0001-01-01T00:00:00Z",
  "ModifiedClient": "2021-03-16T16:35:38.076076Z",
  "Type": "DocumentType",
  "VissibleName": "Cryptic.20210300.New7Wonders_Hunt",
  "CurrentPage": 0,
  "Bookmarked": false,
  "Parent": ""
}
[/]>stat Cryptic.20210300.New7Wonders_Hunt
{
  "ID": "9bc2b5df-839d-4a29-b374-df3d752024c3",
...
[/]>stat Cryptic.20210300.New7Wonders_Hunt
{
  "ID": "9bc2b5df-839d-4a29-b374-df3d752024c3",
[/]>stat Cryptic.20210300.New7Wonders_Hunt
{
  "ID": "9bc2b5df-839d-4a29-b374-df3d752024c3",
...
[/]>stat Cryptic.20210300.New7Wonders_Hunt
{
  "ID": "d7016293-153b-4cc4-8dcd-98ae7585050f",
...
[/]>stat Cryptic.20210300.New7Wonders_Hunt
{
  "ID": "9bc2b5df-839d-4a29-b374-df3d752024c3",
...
[/]>stat Cryptic.20210300.New7Wonders_Hunt
{
  "ID": "39ccd348-ba7e-45e1-bb0f-be573af9c3e4",
  "Version": 8,
  "Message": "",
  "Success": true,
  "BlobURLGet": "",
  "BlobURLGetExpires": "0001-01-01T00:00:00Z",
  "ModifiedClient": "2021-03-15T15:12:30.015015Z",
  "Type": "DocumentType",
  "VissibleName": "Cryptic.20210300.New7Wonders_Hunt",
  "CurrentPage": 6,
  "Bookmarked": false,
  "Parent": ""
}

I'm not sure which one is retrieved with get or mget. mget only got me one of the three files.

Now it is quite simple to fix this for me: by renaming the files or deleting the duplicates, which is what I will do. But the primary reason for using rmapi was exactly because I wanted to have a full backup before trying to remedy this and several other problems.

Maybe rmapi could do something sensible when the user tries to stat, get or mget different files with the same name. It knows when this happens, because the duplicate filenames show up in ls. E.g. rmapi could

hugobuddel commented 3 years ago

The problems get a bit more annoying when there is both a CollectionType (directory) and a DocumentType with the same name. There is only a 50/50 chance that entering a directory works. stating a file in such a directory from outside it (e.g. through rmapi -ni stat DirectoryWithSameNameAsFile/somenormalfile) will only work half of the time (both randomly, so retrying helps).