浏览代码

Some magics

Mario Danic 8 年之前
父节点
当前提交
60325485c6
共有 1 个文件被更改,包括 13 次插入1 次删除
  1. 13 1
      src/com/owncloud/android/services/observer/FileAlterationMagicObserver.java

+ 13 - 1
src/com/owncloud/android/services/observer/FileAlterationMagicObserver.java

@@ -41,6 +41,7 @@ package com.owncloud.android.services.observer;
 import android.os.SystemClock;
 
 import com.owncloud.android.datamodel.SyncedFolder;
+import com.owncloud.android.lib.common.utils.Log_OC;
 import com.owncloud.android.services.FileAlterationMagicListener;
 
 import org.apache.commons.io.FileUtils;
@@ -199,7 +200,18 @@ public class FileAlterationMagicObserver extends FileAlterationObserver implemen
         if (rootFile.exists()) {
             checkAndNotify(rootEntry, rootEntry.getChildren(), listFiles(rootFile));
         } else if (rootEntry.isExists()) {
-            checkAndNotify(rootEntry, rootEntry.getChildren(), FileUtils.EMPTY_FILE_ARRAY);
+            try {
+                // try to init once more
+                init();
+                if (rootEntry.getFile().exists()) {
+                    checkAndNotify(rootEntry, rootEntry.getChildren(), listFiles(rootEntry.getFile()));
+                } else {
+                    checkAndNotify(rootEntry, rootEntry.getChildren(), FileUtils.EMPTY_FILE_ARRAY);
+                }
+            } catch (Exception e) {
+                Log_OC.d("FileAlterationMagicObserver", "Failed getting an observer to intialize " + e);
+                checkAndNotify(rootEntry, rootEntry.getChildren(), FileUtils.EMPTY_FILE_ARRAY);
+            }
         } // else didn't exist and still doesn't
 
         /* fire onStop() */