Merge pull request #324 from owncloud/last_minute_release-1.5.2
[pub/Android/ownCloud.git] / src / com / owncloud / android / datamodel / FileDataStorageManager.java
index 635e10c..042709a 100644 (file)
@@ -25,10 +25,10 @@ import java.util.Collections;
 import java.util.Iterator;
 import java.util.Vector;
 
 import java.util.Iterator;
 import java.util.Vector;
 
-import com.owncloud.android.Log_OC;
 import com.owncloud.android.MainApp;
 import com.owncloud.android.db.ProviderMeta.ProviderTableMeta;
 import com.owncloud.android.utils.FileStorageUtils;
 import com.owncloud.android.MainApp;
 import com.owncloud.android.db.ProviderMeta.ProviderTableMeta;
 import com.owncloud.android.utils.FileStorageUtils;
+import com.owncloud.android.utils.Log_OC;
 
 
 import android.accounts.Account;
 
 
 import android.accounts.Account;
@@ -391,14 +391,16 @@ public class FileDataStorageManager {
         if (id > FileDataStorageManager.ROOT_PARENT_ID) {
             Log_OC.d(TAG, "Updating size of " + id);
             if (getContentResolver() != null) {
         if (id > FileDataStorageManager.ROOT_PARENT_ID) {
             Log_OC.d(TAG, "Updating size of " + id);
             if (getContentResolver() != null) {
-                getContentResolver().update(ProviderTableMeta.CONTENT_URI_DIR, null,
+                getContentResolver().update(ProviderTableMeta.CONTENT_URI_DIR, 
+                        new ContentValues(),    // won't be used, but cannot be null; crashes in KLP
                         ProviderTableMeta._ID + "=?",
                         new String[] { String.valueOf(id) });
             } else {
                 try {
                         ProviderTableMeta._ID + "=?",
                         new String[] { String.valueOf(id) });
             } else {
                 try {
-                    getContentProviderClient().update(ProviderTableMeta.CONTENT_URI_DIR, null,
-                        ProviderTableMeta._ID + "=?",
-                        new String[] { String.valueOf(id) });
+                    getContentProviderClient().update(ProviderTableMeta.CONTENT_URI_DIR, 
+                            new ContentValues(),    // won't be used, but cannot be null; crashes in KLP
+                            ProviderTableMeta._ID + "=?",
+                            new String[] { String.valueOf(id) });
                     
                 } catch (RemoteException e) {
                     Log_OC.e(TAG, "Exception in update of folder size through compatibility patch " + e.getMessage());
                     
                 } catch (RemoteException e) {
                     Log_OC.e(TAG, "Exception in update of folder size through compatibility patch " + e.getMessage());
@@ -432,7 +434,7 @@ public class FileDataStorageManager {
                     }
                     updateFolderSize(file.getParentId());
                 }
                     }
                     updateFolderSize(file.getParentId());
                 }
-                if (removeLocalCopy && file.isDown()) {
+                if (removeLocalCopy && file.isDown() && file.getStoragePath() != null) {
                     boolean success = new File(file.getStoragePath()).delete();
                     if (!removeDBData && success) {
                         // maybe unnecessary, but should be checked TODO remove if unnecessary
                     boolean success = new File(file.getStoragePath()).delete();
                     if (!removeDBData && success) {
                         // maybe unnecessary, but should be checked TODO remove if unnecessary