Loading app/src/main/java/foundation/e/drive/database/DbHelper.java +23 −0 Original line number Diff line number Diff line Loading @@ -298,6 +298,12 @@ public final class DbHelper extends SQLiteOpenHelper { return result; } /** * Look if there is some known file that need to be uploaded for the given syncedFolder * @param syncedFolderID id of the syncedFolder * @param context context * @return true if there is at least one file that need to be uploaded */ public static boolean syncedFolderHasContentToUpload(long syncedFolderID, Context context) { final SyncedFileStateDAO dao; try { Loading @@ -309,6 +315,23 @@ public final class DbHelper extends SQLiteOpenHelper { return false; } /** * Look if there us some known file that need to be downloaded for the given syncedFolder * @param syncedFolderId SyncedFolderId * @param context context * @return true if there is at least one file to download */ public static boolean syncedFolderHasContentToDownload(int syncedFolderId, Context context) { final SyncedFileStateDAO dao; try { dao = openSyncedFileStateDAO(context, false); return dao.countFileWaitingForDownloadForSyncedFolder(syncedFolderId) > 0; } catch (SQLiteException e) { Log.e(TAG, "SQLite error", e); } return false; } /** * Copy database file into user accessible directory for debuging purpose * @return path to the dump or null if failure Loading app/src/main/java/foundation/e/drive/database/SyncedFileStateDAO.java +22 −1 Original line number Diff line number Diff line Loading @@ -148,7 +148,7 @@ class SyncedFileStateDAO { * ONLY list file that can be scan on device side * @param syncedFolderId ID of the given synced folder * @return number of file waiting to be uploaded * @throws SQLiteDoneException SQL return 0 row * @throws SQLiteDoneException SQL return 0 rows */ long countFileWaitingForUploadForSyncedFolder(long syncedFolderId) throws SQLiteDoneException { final String query = "SELECT COUNT(*) FROM " Loading @@ -161,6 +161,25 @@ class SyncedFileStateDAO { return statement.simpleQueryForLong(); } /** * Count number of syncedFileState's entry with an eTag but no value for local last modified * Only file that can be scan on cloud are listed * @param syncedFolderId The id of the syncedFolder * @return number of file waiting to be downloaded * @throws SQLiteDoneException SQL return 0 rows */ long countFileWaitingForDownloadForSyncedFolder(int syncedFolderId) throws SQLiteDoneException{ final String query = "SELECT COUNT(*) FROM " + TABLE_NAME + " WHERE " + SCANNABLE + " IN (1,3)" + " AND " + LOCAL_LAST_MODIFIED + " = 0" + " AND length(" + LAST_ETAG + ") > 0" + " AND " + SYNCEDFOLDER_ID + " = "+syncedFolderId; final SQLiteStatement statement = mDB.compileStatement(query); return statement.simpleQueryForLong(); } /** * Fetch many SyncedFileState by their syncedFolder's id * @param syncedFolderIds List<Long> of id of parent syncedFolder. Loading Loading @@ -254,4 +273,6 @@ class SyncedFileStateDAO { cursor.getInt(8) //scannable ); } } app/src/main/java/foundation/e/drive/operations/ListFileRemoteOperation.java +2 −1 Original line number Diff line number Diff line Loading @@ -113,7 +113,8 @@ public class ListFileRemoteOperation extends RemoteOperation<ArrayList<RemoteFil final int dataSize = result.getData().size(); final RemoteFile directory = (RemoteFile) result.getData().get(0); if (directory.getEtag().equals(syncedFolder.getLastEtag())) { if (directory.getEtag().equals(syncedFolder.getLastEtag()) && !DbHelper.syncedFolderHasContentToDownload(syncedFolder.getId(), context)) { return false; } syncedFolder.setLastEtag(directory.getEtag()).setToSync(true); Loading Loading
app/src/main/java/foundation/e/drive/database/DbHelper.java +23 −0 Original line number Diff line number Diff line Loading @@ -298,6 +298,12 @@ public final class DbHelper extends SQLiteOpenHelper { return result; } /** * Look if there is some known file that need to be uploaded for the given syncedFolder * @param syncedFolderID id of the syncedFolder * @param context context * @return true if there is at least one file that need to be uploaded */ public static boolean syncedFolderHasContentToUpload(long syncedFolderID, Context context) { final SyncedFileStateDAO dao; try { Loading @@ -309,6 +315,23 @@ public final class DbHelper extends SQLiteOpenHelper { return false; } /** * Look if there us some known file that need to be downloaded for the given syncedFolder * @param syncedFolderId SyncedFolderId * @param context context * @return true if there is at least one file to download */ public static boolean syncedFolderHasContentToDownload(int syncedFolderId, Context context) { final SyncedFileStateDAO dao; try { dao = openSyncedFileStateDAO(context, false); return dao.countFileWaitingForDownloadForSyncedFolder(syncedFolderId) > 0; } catch (SQLiteException e) { Log.e(TAG, "SQLite error", e); } return false; } /** * Copy database file into user accessible directory for debuging purpose * @return path to the dump or null if failure Loading
app/src/main/java/foundation/e/drive/database/SyncedFileStateDAO.java +22 −1 Original line number Diff line number Diff line Loading @@ -148,7 +148,7 @@ class SyncedFileStateDAO { * ONLY list file that can be scan on device side * @param syncedFolderId ID of the given synced folder * @return number of file waiting to be uploaded * @throws SQLiteDoneException SQL return 0 row * @throws SQLiteDoneException SQL return 0 rows */ long countFileWaitingForUploadForSyncedFolder(long syncedFolderId) throws SQLiteDoneException { final String query = "SELECT COUNT(*) FROM " Loading @@ -161,6 +161,25 @@ class SyncedFileStateDAO { return statement.simpleQueryForLong(); } /** * Count number of syncedFileState's entry with an eTag but no value for local last modified * Only file that can be scan on cloud are listed * @param syncedFolderId The id of the syncedFolder * @return number of file waiting to be downloaded * @throws SQLiteDoneException SQL return 0 rows */ long countFileWaitingForDownloadForSyncedFolder(int syncedFolderId) throws SQLiteDoneException{ final String query = "SELECT COUNT(*) FROM " + TABLE_NAME + " WHERE " + SCANNABLE + " IN (1,3)" + " AND " + LOCAL_LAST_MODIFIED + " = 0" + " AND length(" + LAST_ETAG + ") > 0" + " AND " + SYNCEDFOLDER_ID + " = "+syncedFolderId; final SQLiteStatement statement = mDB.compileStatement(query); return statement.simpleQueryForLong(); } /** * Fetch many SyncedFileState by their syncedFolder's id * @param syncedFolderIds List<Long> of id of parent syncedFolder. Loading Loading @@ -254,4 +273,6 @@ class SyncedFileStateDAO { cursor.getInt(8) //scannable ); } }
app/src/main/java/foundation/e/drive/operations/ListFileRemoteOperation.java +2 −1 Original line number Diff line number Diff line Loading @@ -113,7 +113,8 @@ public class ListFileRemoteOperation extends RemoteOperation<ArrayList<RemoteFil final int dataSize = result.getData().size(); final RemoteFile directory = (RemoteFile) result.getData().get(0); if (directory.getEtag().equals(syncedFolder.getLastEtag())) { if (directory.getEtag().equals(syncedFolder.getLastEtag()) && !DbHelper.syncedFolderHasContentToDownload(syncedFolder.getId(), context)) { return false; } syncedFolder.setLastEtag(directory.getEtag()).setToSync(true); Loading