Revert "Attempt to fix stuff"

This reverts commit 58b640a8c85f090c9d8b9fc8de342e95a708f7a0.
This commit is contained in:
Mario Danic 2017-02-23 10:39:35 +01:00 committed by AndyScherzinger
parent 8bfdd0047c
commit 49c27b1464
No known key found for this signature in database
GPG key ID: 6CADC7E3523C308B
2 changed files with 21 additions and 27 deletions

View file

@ -92,7 +92,7 @@ public class FileAlterationMagicListener implements FileAlterationListener {
} }
public void onFileCreate(final File file, int delay) { public void onFileCreate(final File file, int delay) {
if (file != null && !uploadMap.containsKey(file.getAbsolutePath())) { if (file != null) {
uploadMap.put(file.getAbsolutePath(), null); uploadMap.put(file.getAbsolutePath(), null);
String mimetypeString = FileStorageUtils.getMimeTypeFromName(file.getAbsolutePath()); String mimetypeString = FileStorageUtils.getMimeTypeFromName(file.getAbsolutePath());

View file

@ -66,7 +66,6 @@ public class FileAlterationMagicObserver extends FileAlterationObserver implemen
private FileFilter fileFilter; private FileFilter fileFilter;
private Comparator<File> comparator; private Comparator<File> comparator;
private SyncedFolder syncedFolder; private SyncedFolder syncedFolder;
private boolean isCheckRunning = false;
private static final FileEntry[] EMPTY_ENTRIES = new FileEntry[0]; private static final FileEntry[] EMPTY_ENTRIES = new FileEntry[0];
@ -219,38 +218,33 @@ public class FileAlterationMagicObserver extends FileAlterationObserver implemen
*/ */
public void checkAndNotify() { public void checkAndNotify() {
if (!isCheckRunning) {
isCheckRunning = true;
/* fire onStart() */ /* fire onStart() */
for (final FileAlterationMagicListener listener : listeners) { for (final FileAlterationMagicListener listener : listeners) {
listener.onStart(this); listener.onStart(this);
} }
/* fire directory/file events */ /* fire directory/file events */
final File rootFile = rootEntry.getFile(); final File rootFile = rootEntry.getFile();
if (rootFile.exists()) { if (rootFile.exists()) {
checkAndNotify(rootEntry, rootEntry.getChildren(), listFiles(rootFile), 2000); checkAndNotify(rootEntry, rootEntry.getChildren(), listFiles(rootFile), 2000);
} else if (rootEntry.isExists()) { } else if (rootEntry.isExists()) {
try { try {
// try to init once more // try to init once more
init(); init();
if (rootEntry.getFile().exists()) { if (rootEntry.getFile().exists()) {
checkAndNotify(rootEntry, rootEntry.getChildren(), listFiles(rootEntry.getFile()), 2000); checkAndNotify(rootEntry, rootEntry.getChildren(), listFiles(rootEntry.getFile()), 2000);
} else { } else {
checkAndNotify(rootEntry, rootEntry.getChildren(), FileUtils.EMPTY_FILE_ARRAY, 2000);
}
} catch (Exception e) {
Log_OC.d("FileAlterationMagicObserver", "Failed getting an observer to intialize " + e);
checkAndNotify(rootEntry, rootEntry.getChildren(), FileUtils.EMPTY_FILE_ARRAY, 2000); checkAndNotify(rootEntry, rootEntry.getChildren(), FileUtils.EMPTY_FILE_ARRAY, 2000);
} }
} // else didn't exist and still doesn't } catch (Exception e) {
Log_OC.d("FileAlterationMagicObserver", "Failed getting an observer to intialize " + e);
checkAndNotify(rootEntry, rootEntry.getChildren(), FileUtils.EMPTY_FILE_ARRAY, 2000);
}
} // else didn't exist and still doesn't
/* fire onStop() */ /* fire onStop() */
for (final FileAlterationMagicListener listener : listeners) { for (final FileAlterationMagicListener listener : listeners) {
listener.onStop(this); listener.onStop(this);
}
isCheckRunning = false;
} }
} }