Skip to content

Commit

Permalink
Revert "Remove useless conditions"
Browse files Browse the repository at this point in the history
This reverts commit 5dd6d91.
  • Loading branch information
mario authored and AndyScherzinger committed Feb 5, 2017
1 parent 9b37348 commit 21aa2ea
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,15 @@ public boolean accept(File pathname) {

file = new File(MainApp.getAppContext().getExternalFilesDir(null).getAbsolutePath() + "/nc_persistence");

boolean readPerstistanceEntries = false;

if (file.exists() ) {
FileInputStream fis = null;
try {
fis = new FileInputStream(file);
ObjectInputStream ois = new ObjectInputStream(fis);
pairArrayList = (CopyOnWriteArrayList<Pair<SyncedFolder, FileEntry>>)ois.readObject();
readPerstistanceEntries = true;
} catch (FileNotFoundException e) {
Log_OC.d(TAG, "Failed with FileNotFound while reading persistence file");
} catch (IOException e) {
Expand Down Expand Up @@ -138,7 +140,7 @@ public boolean accept(File pathname) {
}
}

writePersistenceEntries(file);
writePersistenceEntries(readPerstistanceEntries, file);

try {
monitor.start();
Expand All @@ -150,11 +152,11 @@ public boolean accept(File pathname) {
return Service.START_NOT_STICKY;
}

private void writePersistenceEntries(File file) {
private void writePersistenceEntries(boolean readPerstistanceEntries, File file) {
FileOutputStream fos = null;

try {
if (pairArrayList.size() > 0) {
if (pairArrayList.size() > 0 && !readPerstistanceEntries) {
fos = MainApp.getAppContext().openFileOutput(file.getAbsolutePath(), Context.MODE_PRIVATE);
ObjectOutputStream os = new ObjectOutputStream(fos);
for (int i = 0; i < pairArrayList.size(); i++) {
Expand Down Expand Up @@ -199,7 +201,7 @@ public void onDestroy() {
}
}

writePersistenceEntries(file);
writePersistenceEntries(false, file);
}

/**
Expand Down Expand Up @@ -262,7 +264,7 @@ public void restartObserver(SyncedFolder syncedFolder) {
}
}

writePersistenceEntries(file);
writePersistenceEntries(false, file);
}

@Override
Expand Down

0 comments on commit 21aa2ea

Please sign in to comment.