- String path = c.getString(c.getColumnIndex(ProviderTableMeta.FILE_STORAGE_PATH));
- if (path == null || path.length() <= 0)
- continue;
- OwnCloudFileObserver observer =
- new OwnCloudFileObserver( path,
- account,
- getApplicationContext(),
- OwnCloudFileObserver.CHANGES_ONLY);
- mObserversMap.put(path, observer);
- if (new File(path).exists()) {
- observer.startWatching();
- Log_OC.d(TAG, "Started watching file " + path);
+ OwnCloudFileObserver observer = mObserversMap.get(localPath);
+ if (observer == null) {
+ observer = new OwnCloudFileObserver(
+ localPath, account, getApplicationContext()
+ );
+ mObserversMap.put(localPath, observer);
+
+ // only if being added
+ if (new File(localPath).exists()) {
+ observer.startWatching();
+ Log_OC.d(TAG, "Started watching file " + localPath);
+ }
+ }
+
+ /*
+ String parentPath = (new File(localPath)).getParent();
+ OwnCloudFileObserver observerParent =
+ new OwnCloudFileObserver( parentPath,
+ account,
+ getApplicationContext());
+ mObserverParentsMap.put(parentPath, observer);
+
+ if (new File(localPath).exists()) {
+ observer.startWatching();
+ Log_OC.d(TAG, "Started watching file " + localPath);
+ observerParent.startWatching();
+ Log_OC.d(TAG, "Started watching parent file " + parentPath);
+ }
+ */
+
+ } while (cursorOnKeptInSync.moveToNext());
+