Fixed bug in which a newly created and unedited project would never get saved because it had the same modified time and last save time.

git-svn-id: http://google-refine.googlecode.com/svn/trunk@1530 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
David Huynh 2010-10-14 01:43:26 +00:00
parent 1f1586715d
commit 4ccdbc8716

View File

@ -204,7 +204,7 @@ public abstract class ProjectManager {
protected void saveProjects(boolean allModified) {
List<SaveRecord> records = new ArrayList<SaveRecord>();
Date startTimeOfSave = new Date();
synchronized (this) {
for (long id : _projectsMetadata.keySet()) {
ProjectMetadata metadata = getProjectMetadata(id);
@ -212,7 +212,10 @@ public abstract class ProjectManager {
if (project != null) {
boolean hasUnsavedChanges =
metadata.getModified().getTime() > project.getLastSave().getTime();
metadata.getModified().getTime() >= project.getLastSave().getTime();
// We use >= instead of just > to avoid the case where a newly created project
// has the same modified and last save times, resulting in the project not getting
// saved at all.
if (hasUnsavedChanges) {
long msecsOverdue = startTimeOfSave.getTime() - project.getLastSave().getTime();
@ -229,7 +232,7 @@ public abstract class ProjectManager {
}
}
}
if (records.size() > 0) {
Collections.sort(records, new Comparator<SaveRecord>() {
public int compare(SaveRecord o1, SaveRecord o2) {