Posts: 1,903
Threads: 296
Joined: Sep 2014
Reputation:
33
I manage my files myself, use identical files and subfolders within the MSP folder and copy mobilesheets.db manually from my Android tablet to my Win10 laptop.
As MSP uses relative paths this usually works fine but sometimes it doesn't.
This is caused by the fact that the same folder is mounted on Android more than once with different path names.
It would be great if MSP could handle that correctly.
Details:
MSP folder on Android: /storage/emulated/0/_MobileSheets
MSP folder on Win10: D:\HerbertsGoogleDrive\_MobileSheets
Exactly the same files and subfolders exist within _MobileSheets\Fkbk0
The Android tablet runs Android 4.4
I add three files from the same subfolder "MSPTest" to my library on the Android tablet.
When I copy the library to my Win10 laptop some of the files are reported as missing despite all files exist.
Textsize25.png has been selected on Android from
storage - emulated - legacy - _MobileSheets ...
shows up on Android on the "Files" tab of the SongEditor as
/storage/emulated/legacy/_MobileSheets/Fkbk0/MSPTest/Textsize25.png
shows up on Win10 on the "Files" tab of the SongEditor as
/storage/emulated/legacy/_MobileSheets/Fkbk0/MSPTest/Textsize25.png
=> reported as missing
Comments1.png has been selected on Android from
storage - sdcard0 - _MobileSheets ...
shows up on Android on the "Files" tab of the SongEditor as
/storage/emulated/legacy/_MobileSheets/Fkbk0/MSPTest/Comments1.png
shows up on Win10 on the "Files" tab of the SongEditor as
/storage/emulated/legacy/_MobileSheets/Fkbk0/MSPTest/Comments1.png
=> reported as missing
Comments2.png has been selected on Android from
storage - emulated - 0 - _MobileSheets ...
shows up on Android on the "Files" tab of the SongEditor as
/storage/emulated/0/_MobileSheets/Fkbk0/MSPTest/Comments2.png
shows up on Win10 on the "Files" tab of the SongEditor as
D:\HerbertsGoogleDrive\_MobileSheets\Fkbk0\MSPTest\Comments2.png
=> this one is OK
=> it has been stored in the database with relative path
=> so on Win10 the path has been handled correctly
Posts: 13,539
Threads: 302
Joined: Apr 2012
Reputation:
241
03-29-2019, 02:57 PM
(This post was last modified: 03-29-2019, 02:58 PM by Zubersoft.)
I do try to handle it correctly, believe me. I have added lots of code to try to simplify paths into their canonical form, which should give me the same path in every case. Things are never that simple though. Google does not make it simple to determine if one path is the same thing as another. There is no simple check I can do to say, "does /storage/emulated/0 mean the same thing as /storage/emulated/legacy". I also tried to avoid hardcoding paths to force replacements of /storage/emulated/legacy with /storage/emulated/0 as it did not seem like the right thing to do. I believe newer Android OS versions handle this more gracefully. Direct access is no longer possible to anything but /storage/emulated/0, and there is no /storage/emulated/legacy. So the possibility of having conflicting paths like that on newer Android versions is no longer an issue.
Let me ask this - how are you getting into the scenario where you are selecting files from /storage/emulated/legacy? Can you just ensure you are always adding files from /storage/emulated/0? What storage location is listed under Settings->Storage->Set MobileSheets Storage Location? Can you ensure that path is set to /storage/emulated/0?
Mike
Posts: 1,903
Threads: 296
Joined: Sep 2014
Reputation:
33
how are you getting into the scenario where you are selecting files from /storage/emulated/legacy
MSPs file selector allows selecting from there, both for "Import - Local File" and "Import - CSV or PDF Bookmarks" (and probably everywhere else)
Can you just ensure you are always adding files from /storage/emulated/0?
Yes. But only if I keep in mind to avoid "legacy".
What storage location is listed under Settings->Storage->Set MobileSheets Storage Location?
Can you ensure that path is set to /storage/emulated/0?
Yes, I'm sure. I read the path from MSP settings.
Posts: 1,903
Threads: 296
Joined: Sep 2014
Reputation:
33
Fixing that fie path issue:
On Android I can fix it easily with "Swap File" or "Fix Broken File Paths"
The "Swap File" options window has a checkbox "Copy or Move New File"
On Win10 i came across some issues that imho need to be fixed.
Using "Swap File"
The checkbox "Copy or Move New File" is missing in the "Swap File" options window
So I had to make a choice in the selection list. None of them really matched. I chose
"Move new file to same folder as replaced file"
That lead to a NullReferenceException
When I click OK MSP keeps running correctly, the path stays unchanged.
Using "Fix Broken FIle Paths" leads to an error
"Failed to update the database. You might need to fully close and reopen the app"
showing the "busy circle" for a long time (forever?). Cancel did not work
Additional proposals:
It's a good idea that clicking on the path in "Find Missing Files" result window starts a "Swap File" operation.
It would be even better to have the choice between "copy path to clipboard", "Swap Files" and "Fix Broken File Paths"
"Fix Broken File Paths" should accept not only folder paths. It woud be better if it accepted both folder paths and file paths including the file name. Possibly a file has not only be moved to a different folder but also renamed in the same step.
Posts: 13,539
Threads: 302
Joined: Apr 2012
Reputation:
241
I'll look into those issues. A simple test did not reproduce the error you are seeing. I believe that is only caused by having an invalid path from an Android backup and then using the swap file feature to replace that file. Would you mind sending me mobilesheets.db from your LocalState folder so that I can test with a song you know is broken? That would make things much easier for me.
Thanks,
Mike
Posts: 1,903
Threads: 296
Joined: Sep 2014
Reputation:
33
I have sent my mobilesheets.db by e-mail.
Try e.g. "Comments1" from Collection MSPTest. "Find Missing Files" shows you more examples in other collections.
Yes, it is caused by having an invalid path from an Android backup.
Please add the missing checkbox "Move new file to same folder as replaced file" anyway.
It is required when I manage my files myself and the file is already where I want it to be.
Posts: 13,539
Threads: 302
Joined: Apr 2012
Reputation:
241
Thanks for the database - I will see what I can find.
That option is only shown if the file being replaced is actually in the storage location. Otherwise there is no way to replace a file that isn't currently in the storage location in Windows 10 due to file permissions. The fact that the path is invalid means MobileSheets won't know how to replace an existing file that is in an invalid or inaccessible location. So the only option you are given is to copy or move the file to the storage location. If a relative path was used for the file, then MobileSheets would be able to correctly handle it and those options would be available. Due to the file having an absolute path, MobileSheets has to respect that. As for why Android is packaging the full path instead of a relative path if the file doesn't exist is a separate matter. I'll have to investigate that if that is what you are seeing.
Thanks,
Mike
Posts: 1,903
Threads: 296
Joined: Sep 2014
Reputation:
33
I understand.
The resulting action should be "just replace the path in the database, don't touch the according files" - that's what I inteded to do and what is specified in the Android version by unchecking "Copy or Move New File"
A better way to implement that as a UI would be to show the checkbox "Copy or Move New File" deactivated (greyed).
This signals that the option exists, but can be used only in certain situations.
I should not be able to select one of the copy / move actions. Probably it doesn't matter at all what I selected there.
If the selection list is shown as deactivated or completely invisible is a matter of taste
Posts: 13,539
Threads: 302
Joined: Apr 2012
Reputation:
241
I can add the checkbox like on Android if the file is already in the storage location. It would be disabled otherwise. As far as the dropdown, I have changed the UI to disable those options instead of hiding them. That is something that I can do on Windows that I probably can't do on Android, so I didn't even think to try it before.
Thanks,
Mike
Posts: 1,903
Threads: 296
Joined: Sep 2014
Reputation:
33
@Mike: I checked again the details for the issue reported in that thread.
There are three possibilities to select the internal memory of my Android devices:
storage/emulated/0
storage/emulated/legacy
storage/sdcard0
Only storage/emulated/0 works correctly.
The behaviour is the same on Android 4.4 and 5.0
I sent you an e-mail with hopefully helpul test data
Posts: 1,903
Threads: 296
Joined: Sep 2014
Reputation:
33
I had some e-mail discussion with Mike that I want to bring back to the forum.
It seems to be difficult to make sure that relative paths are used in any case.
Mike wrote
"... While I would like to add specific checks for those paths to fix them if needed, the problem is that it absolutely could break things for some users. For example, with newer Android versions, you can adopt an SD card as your primary storage, so I have no idea if you do this if /storage/emulated/0 is used or if there is a completely different set of rules. ..."
So here's my summary and alternative proposal:
In cases that I reported above, file paths are not stored as relative paths in MSP on Android as expected. If I copy a database with those paths to MSP on Win10 the paths are invalid.
The issues that prevent repairing the invalid paths on the Win10 device are fixed. The fixes shall be included in one of the next MSP versions.
I can avoid problems if I ALWAYS use storage/emulated/0 and NEVER use storage/emulated/legacy or storage/sdcard0
The only remaining open issue is that I'm not able to notice easily on the Android device if there are paths in the library that are not relative, within the MSP folder and will cause problems when the database is copied to MSP on a Win10 device.
my proposal:
Please add file paths (%FILE_PATHS%) to the list of searchable fields in the filter toolbar.
Thus I can search for paths containing "storage", "legacy" or "sdcard0" and fix them easily using "Swap File" or "Fix Broken File Paths".
This should be a small change with almost no side effects that is easy to test. And it might be useful also in some other cases.
|