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
fixes #4957 new approach for local storage #6396
Conversation
@pstorch, thanks for your PR! By analyzing the history of the files in this pull request, we identified @samueltardieu, @Bananeweizen and @marco-dev to be potential reviewers. |
f36b6a0
to
05643b3
Compare
Looks like codacy has some problems with checking this PR. It doesn't show up here and on codacy.com it checks and checks and checks ... |
05643b3
to
68a5045
Compare
Codacy is fixed. |
68a5045
to
63ce7c7
Compare
Fixed open Issues from #4957 (comment). |
Will test it again this evening or tomorrow |
That is strange: |
If I m not mistaken, release/nigthly/legacy are build on master node using "main" keys. PR are built on sam1/2, keys _may_ differ here.
…On March 17, 2017 9:51:20 AM GMT+01:00, Lars ***@***.***> wrote:
That is strange:
I went the same way I used for the first test:
Installed an older debug.apk retrieved from CI, then wanted to update
to [this](http://ci.cgeo.org/job/cgeo%20pull%20request/801/) debug.apk.
But installation fails, as the signature is different. Do we use
different signatures on CI?
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
#6396 (comment)
--
Sent from my Android device with K-9 Mail. Please excuse my brevity.
|
retest this please |
887bfa2
to
c2ec89a
Compare
retest this please |
(HtmlImage.SHARED.equals(name) || LocalStorage.GEOCACHE_FILE_PATTERN.matcher(name).find()); | ||
} | ||
}; | ||
final File[] list = LocalStorage.getLegacyExternalCgeoDirectory().listFiles(geocacheDirectories); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
listFiles can return null. That should not happen, but me may want to be safe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the other hand, if getLegacyExternalCgeoDirectory()
is supposed to be a directory, then we might want to crash if it isn't :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As described below, I think I should catch null here to be more fault tolerant.
final String urlExt; | ||
if (url.startsWith("data:")) { | ||
// "data:image/png;base64,i53…" -> ".png" | ||
urlExt = StringUtils.substringAfter(StringUtils.substringBefore(url, ";"), "/"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
StringUtils.substringBetween(...)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have to handle null
if you use substringBetween
(the current construct returns an empty string) if it doesn't match. I'm not sure the subsequent call to defaultString
will get better performances, but it may indeed may more readable as
StringUtils.defaultString(StringUtils.substringBetween("/", ";"));
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't thought about this line, because I just moved it here from somewhere else ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I recognized this code, but I couldn't tell why I chose after
+before
instead of between
+default
.
I've just been wondering about the fault tolerance of that migration. E.g. if one of the operation fails, should we still continue with some of the other? That is, should we try-catch several blocks in the migration code? And how much time will this take, if a user has 5000 caches on disk? I believe we don't show any UI about this, so he might decide to stop the application for any reason. Could that lead to issues? |
Regarding fault tolerance: at the moment I'm more in favor of being tolerant and don't stop. The migration and the moving of the Geocache data directory can go wrong easily. The source directory might be missing, some target dirs might already be there. What about no disk space is left? Currently I try to do what is possible and skip over errors, so the user doesn't get stuck. Some cached data might not be copied, but it remains on the other disk and is recoverable. We have to deal with partly migrations anyway, because a filesystem doesn't work with transactions. The copy of the Geocache data has a UI progress dialog. I don't know how long copying of 5000 caches would take. Unfortunately I don't have a device with a real extSdCard. Maybe I should still order one for testing. Or @Lineflyer might be able to test such a volume. |
* Add spoilers stored locally in <tt>/sdcard/GeocachePhotos</tt>. If a cache is named GC123ABC, the | ||
* directory will be <tt>/sdcard/GeocachePhotos/C/B/GC123ABC/</tt>. | ||
* Add spoilers stored locally in <tt>/sdcard/cgeo/GeocachePhotos</tt>. If a cache is named GC123ABC, the | ||
* directory will be <tt>/sdcard/cgeo/GeocachePhotos/C/B/GC123ABC/</tt>. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the choice of not using cgeo
in the path name was because additional data imported from geocaching software could be used by several applications, and did not belong to cgeo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to reread all threads on the subject, and it looks like this has no importance after all, so feel free to rename.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I could find it, it's from a GSAK macro. I also found the corresponding issues and commits here: #4957 (comment)
When I look into the GSAK macro it is actually Garmin\GeocachePhotos
. So the user of this macro need to copy the subfolder anyhow. I don't know if this directory might be used by some other Apps in parallel. Should we keep it one level up?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably not. As you say, it has to be moved through a file manager or similar anyway, so your proposed change is fine.
c2ec89a
to
cecbe0e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good to go from testing/Ui perspective
Maybe it's time to get some first feedback.
It's implementing the https://github.com/cgeo/cgeo/wiki/Target-disk-usage-structure
❗ If you want to test it, be careful: it moves your files around. ❗