From: masensio Date: Thu, 11 Jul 2013 16:57:35 +0000 (+0200) Subject: OC-673: Show folder size at a first sync X-Git-Tag: oc-android-1.4.3~3 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/5f0dfa61abe83bafaa32393b0d9d0edcd19dffb1 OC-673: Show folder size at a first sync --- diff --git a/src/com/owncloud/android/datamodel/FileDataStorageManager.java b/src/com/owncloud/android/datamodel/FileDataStorageManager.java index d84eb2a0..6a2d538b 100644 --- a/src/com/owncloud/android/datamodel/FileDataStorageManager.java +++ b/src/com/owncloud/android/datamodel/FileDataStorageManager.java @@ -235,6 +235,12 @@ public class FileDataStorageManager implements DataStorageManager { if (fileExists(file.getRemotePath())) { OCFile oldFile = getFileByPath(file.getRemotePath()); file.setFileId(oldFile.getFileId()); + + if (file.isDirectory()) { + cv.put(ProviderTableMeta.FILE_CONTENT_LENGTH, oldFile.getFileLength()); + file.setFileLength(oldFile.getFileLength()); + } + operations.add(ContentProviderOperation.newUpdate(ProviderTableMeta.CONTENT_URI). withValues(cv). withSelection( ProviderTableMeta._ID + "=?", @@ -245,9 +251,14 @@ public class FileDataStorageManager implements DataStorageManager { OCFile oldFile = getFileById(file.getFileId()); if (file.getStoragePath() == null && oldFile.getStoragePath() != null) file.setStoragePath(oldFile.getStoragePath()); - if (!file.isDirectory()); - cv.put(ProviderTableMeta.FILE_STORAGE_PATH, file.getStoragePath()); - + + if (!file.isDirectory()) + cv.put(ProviderTableMeta.FILE_STORAGE_PATH, file.getStoragePath()); + else { + cv.put(ProviderTableMeta.FILE_CONTENT_LENGTH, oldFile.getFileLength()); + file.setFileLength(oldFile.getFileLength()); + } + operations.add(ContentProviderOperation.newUpdate(ProviderTableMeta.CONTENT_URI). withValues(cv). withSelection( ProviderTableMeta._ID + "=?", diff --git a/src/com/owncloud/android/syncadapter/FileSyncAdapter.java b/src/com/owncloud/android/syncadapter/FileSyncAdapter.java index 44fe4014..8653fe78 100644 --- a/src/com/owncloud/android/syncadapter/FileSyncAdapter.java +++ b/src/com/owncloud/android/syncadapter/FileSyncAdapter.java @@ -220,6 +220,8 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter { List children = synchFolderOp.getChildren(); fetchChildren(children); // beware of the 'hidden' recursion here! + sendStickyBroadcast(true, remotePath, null); + } else { if (result.getCode() == RemoteOperationResult.ResultCode.UNAUTHORIZED) { mSyncResult.stats.numAuthExceptions++; @@ -267,7 +269,7 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter { fetchData(newFile.getRemotePath(), newFile.getFileId()); // Update folder size on DB - getStorageManager().calculateFolderSize(newFile.getFileId()); + getStorageManager().calculateFolderSize(newFile.getFileId()); } }