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

fixes #4957 new approach for local storage #6396

Merged
merged 1 commit into from Mar 21, 2017

Conversation

pstorch
Copy link
Contributor

@pstorch pstorch commented Mar 11, 2017

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. ❗

@pstorch pstorch added the Do not merge / WIP Not for merging and/or work still in progress label Mar 11, 2017
@mention-bot
Copy link

@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.

@pstorch
Copy link
Contributor Author

pstorch commented Mar 12, 2017

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 ...

@pstorch
Copy link
Contributor Author

pstorch commented Mar 14, 2017

Codacy is fixed.

@pstorch
Copy link
Contributor Author

pstorch commented Mar 16, 2017

Fixed open Issues from #4957 (comment).

@Lineflyer
Copy link
Member

Will test it again this evening or tomorrow

@Lineflyer Lineflyer self-assigned this Mar 17, 2017
@Lineflyer Lineflyer added the Field test Issue to be (re)tested in the field label Mar 17, 2017
@Lineflyer
Copy link
Member

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 debug.apk. But installation fails, as the signature is different. Do we use different signatures on CI?

@kumy
Copy link
Member

kumy commented Mar 17, 2017 via email

@Lineflyer
Copy link
Member

retest this please

@pstorch pstorch force-pushed the 4957_new_local_storage branch 2 times, most recently from 887bfa2 to c2ec89a Compare March 20, 2017 21:42
@pstorch
Copy link
Contributor Author

pstorch commented Mar 20, 2017

retest this please

(HtmlImage.SHARED.equals(name) || LocalStorage.GEOCACHE_FILE_PATTERN.matcher(name).find());
}
};
final File[] list = LocalStorage.getLegacyExternalCgeoDirectory().listFiles(geocacheDirectories);
Copy link
Member

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.

Copy link
Member

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 :)

Copy link
Contributor Author

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, ";"), "/");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

StringUtils.substringBetween(...)?

Copy link
Member

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("/", ";"));

Copy link
Contributor Author

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 ;)

Copy link
Member

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.

@Bananeweizen
Copy link
Member

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?

@pstorch
Copy link
Contributor Author

pstorch commented Mar 21, 2017

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.
This is just my view on this, let's discuss.

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>.
Copy link
Member

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.

Copy link
Member

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.

Copy link
Contributor Author

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?

Copy link
Member

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.

@pstorch pstorch removed the Do not merge / WIP Not for merging and/or work still in progress label Mar 21, 2017
@samueltardieu samueltardieu merged commit 0a0b6a8 into cgeo:master Mar 21, 2017
@Lineflyer Lineflyer removed their assignment Mar 21, 2017
@Lineflyer Lineflyer removed the Field test Issue to be (re)tested in the field label Mar 21, 2017
Copy link
Member

@Lineflyer Lineflyer left a 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

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

Successfully merging this pull request may close these issues.

None yet

6 participants