Skip to content
This repository has been archived by the owner on Jul 26, 2022. It is now read-only.

Commit

Permalink
Sorting list and fixing test
Browse files Browse the repository at this point in the history
  • Loading branch information
pimotte committed Aug 8, 2014
1 parent 93f5b91 commit abd4f4a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Expand Up @@ -20,6 +20,7 @@
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
Expand Down Expand Up @@ -327,7 +328,7 @@ private boolean hasRemoteChanges() throws Exception {
}

private void mergeRemoteFiles() throws IOException, StorageException {
// Retrieve and sort machine's database versions
// Retrieve all database versions
Map<String, List<DatabaseRemoteFile>> allDatabaseFilesMap = retrieveAllRemoteDatabaseFiles();

List<DatabaseRemoteFile> allToDeleteDatabaseFiles = new ArrayList<DatabaseRemoteFile>();
Expand All @@ -343,14 +344,16 @@ private void mergeRemoteFiles() throws IOException, StorageException {

for (String client : allDatabaseFilesMap.keySet()) {
List<DatabaseRemoteFile> clientDatabaseFiles = allDatabaseFilesMap.get(client);
Collections.sort(clientDatabaseFiles);
logger.log(Level.INFO, "Databases: " + clientDatabaseFiles);

// Now do the merge!
logger.log(Level.INFO, "- Merge remote files: Merging necessary ({0} database files, max. {1}) ...",
new Object[] { clientDatabaseFiles.size(), MAX_KEEP_DATABASE_VERSIONS });

// 1. Determine files to delete remotely
List<DatabaseRemoteFile> toDeleteDatabaseFiles = new ArrayList<DatabaseRemoteFile>();
int numOfDatabaseFilesToDelete = clientDatabaseFiles.size() - 1, 0;
int numOfDatabaseFilesToDelete = clientDatabaseFiles.size() - 1;

// This client needs no merging
if (numOfDatabaseFilesToDelete == 0) {
Expand Down
Expand Up @@ -93,7 +93,8 @@ public void testCleanupMergeDatabaseFilesScenario1() throws Exception {
assertFalse(new File(testConnection.getRepositoryPath(), "databases/db-A-0000000001").exists());
assertFalse(new File(testConnection.getRepositoryPath(), "databases/db-A-0000000005").exists());
assertFalse(new File(testConnection.getRepositoryPath(), "databases/db-A-0000000010").exists());
assertTrue(new File(testConnection.getRepositoryPath(), "databases/db-A-0000000011").exists());
assertFalse(new File(testConnection.getRepositoryPath(), "databases/db-A-0000000014").exists());
assertTrue(new File(testConnection.getRepositoryPath(), "databases/db-A-0000000015").exists());

// Run
clientC.down(); // <<< Here is/was the issue: Client C failed when downloading
Expand Down

0 comments on commit abd4f4a

Please sign in to comment.