Set latest seen version after non empty snapshot fetch.

This commit is contained in:
Winston Li
2015-02-22 01:02:35 +00:00
parent 680c7fabf7
commit 4a396c2c17
2 changed files with 8 additions and 5 deletions

View File

@@ -17,10 +17,10 @@ import java.util.*;
*/
public class SnapshotFetcher {
public List<Snapshot> getSnapshotsForProjectAfterVersion(String projectName, int version) throws FailedConnectionException, SnapshotPostException {
public LinkedList<Snapshot> getSnapshotsForProjectAfterVersion(String projectName, int version) throws FailedConnectionException, SnapshotPostException {
List<SnapshotInfo> snapshotInfos = getSnapshotInfosAfterVersion(projectName, version);
List<SnapshotData> snapshotDatas = getMatchingSnapshotData(projectName, snapshotInfos);
List<Snapshot> snapshots = combine(snapshotInfos, snapshotDatas);
LinkedList<Snapshot> snapshots = combine(snapshotInfos, snapshotDatas);
return snapshots;
}
@@ -63,8 +63,8 @@ public class SnapshotFetcher {
return requests;
}
private List<Snapshot> combine(List<SnapshotInfo> snapshotInfos, List<SnapshotData> snapshotDatas) {
List<Snapshot> snapshots = new LinkedList<Snapshot>();
private LinkedList<Snapshot> combine(List<SnapshotInfo> snapshotInfos, List<SnapshotData> snapshotDatas) {
LinkedList<Snapshot> snapshots = new LinkedList<Snapshot>();
Iterator<SnapshotInfo> infos = snapshotInfos.iterator();
Iterator<SnapshotData> datas = snapshotDatas.iterator();
while (infos.hasNext()) {

View File

@@ -38,7 +38,10 @@ public class DataStore implements CandidateSnapshotCallback {
}
public List<WritableRepositoryContents> updateProjectWithName(String name, Repository repository) throws IOException, SnapshotPostException {
List<Snapshot> snapshots = snapshotFetcher.getSnapshotsForProjectAfterVersion(name, persistentStore.getLatestVersionForProject(name));
LinkedList<Snapshot> snapshots = snapshotFetcher.getSnapshotsForProjectAfterVersion(name, persistentStore.getLatestVersionForProject(name));
if (!snapshots.isEmpty()) {
persistentStore.setLatestVersionForProject(name, snapshots.getLast().getVersionID());
}
List<WritableRepositoryContents> commits = makeCommitsFromSnapshots(name, repository, snapshots);
return commits;
}