Skip to content

Commit

Permalink
Only reset old storage folder when not needed anymore...
Browse files Browse the repository at this point in the history
  • Loading branch information
RobbWatershed committed Jun 10, 2020
1 parent 1a2c3c2 commit 2321e67
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,11 @@ private void migrateLibrary(@NonNull final List<LogUtil.LogEntry> log, @NonNull
Content content = dao.selectContent(contentId);
if (content != null) {
try {
// Reset the book's storage folder to avoid running the migration service again and again
content.resetStorageFolder();

// Set the book's storage URI
Map<String, DocumentFile> siteFolder = bookFoldersCache.get(content.getSite().getDescription());
if (null == siteFolder) {
trace(Log.WARN, log, "Migrate book KO : site folder %s not found for %s [%s]", content.getSite().getDescription(), content.getTitle(), contentId + "");
content.resetStorageFolder();
dao.insertContent(content);
booksKO++;
continue;
Expand All @@ -203,11 +201,13 @@ private void migrateLibrary(@NonNull final List<LogUtil.LogEntry> log, @NonNull
DocumentFile bookFolder = siteFolder.get(bookFolderName);
if (null == bookFolder) {
trace(Log.WARN, log, "Migrate book KO : book folder %s not found in %s for %s [%s]", bookFolderName, content.getSite().getDescription(), content.getTitle(), contentId + "");
content.resetStorageFolder();
dao.insertContent(content);
booksKO++;
continue;
}
content.setStorageUri(bookFolder.getUri().toString());
content.resetStorageFolder();

// Delete the JSON URI if not in the correct format (file:// instead of content://)
// (might be the case when the migrated collection was stored on phone memory)
Expand Down

0 comments on commit 2321e67

Please sign in to comment.