fixed sync and timestamp when using workshop
This commit is contained in:
parent
a3ce01014e
commit
610d2e77b1
@ -1244,7 +1244,6 @@ public class LauncherGUI implements Observer {
|
||||
techCheck();
|
||||
} else if (s.equals("syncStopped")) {
|
||||
final Parameter workshopParameter = Parameters.USE_WORKSHOP.toParameter();
|
||||
fileCheck(!(workshopParameter.getValue() != null && (boolean) workshopParameter.getValue()));
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
syncDownloadButton.setEnabled(false);
|
||||
syncDownloadAbortButton.setEnabled(false);
|
||||
@ -1253,11 +1252,14 @@ public class LauncherGUI implements Observer {
|
||||
syncStatusLabel.setText("Sync stopped");
|
||||
TaskBarUtils.getInstance().setValue(0);
|
||||
TaskBarUtils.getInstance().off();
|
||||
|
||||
if (workshopParameter.getValue() != null && (boolean) workshopParameter.getValue()) checkType = FileChecker.Type.SLOW;
|
||||
else checkType = FileChecker.Type.FAST;
|
||||
RepositoryManger.getInstance().refreshModset();
|
||||
});
|
||||
techCheck();
|
||||
} else if (s.equals("syncComplete")) {
|
||||
final Parameter workshopParameter = Parameters.USE_WORKSHOP.toParameter();
|
||||
fileCheck(!(workshopParameter.getValue() != null && (boolean) workshopParameter.getValue()));
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
syncDownloadButton.setEnabled(false);
|
||||
syncDownloadAbortButton.setEnabled(false);
|
||||
@ -1268,6 +1270,10 @@ public class LauncherGUI implements Observer {
|
||||
TaskBarUtils.getInstance().off();
|
||||
TaskBarUtils.getInstance().attention();
|
||||
TaskBarUtils.getInstance().notification("Sync complete", "", TrayIcon.MessageType.INFO);
|
||||
|
||||
if (workshopParameter.getValue() != null && (boolean) workshopParameter.getValue()) checkType = FileChecker.Type.SLOW;
|
||||
else checkType = FileChecker.Type.FAST;
|
||||
RepositoryManger.getInstance().refreshModset();
|
||||
});
|
||||
techCheck();
|
||||
} else if (s.equals("syncContinue")) {
|
||||
@ -1315,6 +1321,7 @@ public class LauncherGUI implements Observer {
|
||||
syncIntensiveCheckButton.setEnabled(false);
|
||||
syncFastCheckButton.setEnabled(false);
|
||||
syncCheckAbortButton.setEnabled(true);
|
||||
syncCheckProgress.setValue(0);
|
||||
syncCheckStatusLabel.setText("Running!");
|
||||
new Thread(() -> fileChecker.check(fastscan)).start();
|
||||
|
||||
@ -1325,6 +1332,10 @@ public class LauncherGUI implements Observer {
|
||||
repoTree.setCheckboxesEnabled(false);
|
||||
repoTree.setCheckboxesChecked(false);
|
||||
|
||||
syncSizeLabel.setText("0.0 B/0.0 B");
|
||||
syncFileCountLabel.setText("");
|
||||
syncDownloadSpeedLabel.setText("");
|
||||
|
||||
playButton.setEnabled(false);
|
||||
playPresetButton.setEnabled(false);
|
||||
}
|
||||
|
@ -29,7 +29,6 @@ public class ModFile implements AbstractMod {
|
||||
private String parent;
|
||||
private String localGeneratedSHA1sum = "";
|
||||
private long lastModified = -1;
|
||||
private long localLastModified = -1;
|
||||
|
||||
public ModFile(File f, String modfile, String parent, long size, String sha1sum, long lastModified) {
|
||||
// File: Abosolut Path
|
||||
@ -95,11 +94,7 @@ public class ModFile implements AbstractMod {
|
||||
}
|
||||
|
||||
public long getLocalLastModified() {
|
||||
if (localLastModified <= 0 && exists()) {
|
||||
localLastModified = (int) (f.lastModified() / 1000);
|
||||
}
|
||||
|
||||
return localLastModified;
|
||||
return (int) (f.lastModified() / 1000);
|
||||
}
|
||||
|
||||
public long getLastModified() {
|
||||
|
@ -137,15 +137,18 @@ public class FileChecker implements Observable {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (mf.getLocalSize() != mf.getSize()
|
||||
|| mf.getLocalLastModified() != mf.getLastModified()
|
||||
|| (!fastscan && !mf.getSHA1Sum().equalsIgnoreCase(mf.getLocalGeneratedSHA1Sum()))) {
|
||||
int reason = -1;
|
||||
if(mf.getLocalSize() != mf.getSize()) reason = 0;
|
||||
else if (mf.getLocalLastModified() != mf.getLastModified()) reason = 1;
|
||||
else if (!fastscan && !mf.getSHA1Sum().equalsIgnoreCase(mf.getLocalGeneratedSHA1Sum())) reason = 2;
|
||||
|
||||
if (reason != -1) {
|
||||
if (changed.containsKey(mod)) temp = changed.get(mod);
|
||||
temp.add(mf);
|
||||
changed.put(mod, temp);
|
||||
changedCount++;
|
||||
size += mf.getSize();
|
||||
logger.debug("File {} changed", mf.getLocaleFile().getAbsolutePath());
|
||||
logger.debug("File {} changed. Reason: {}", mf.getLocaleFile().getAbsolutePath(), reason);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -161,6 +161,14 @@ public class Syncer implements Observable, SyncListener {
|
||||
logger.info("ZSync - Copied");
|
||||
SwingUtilities.invokeLater(() -> gui.syncStatusLabel.setText(mfModPath + ": Copied"));
|
||||
success++;
|
||||
|
||||
long lastMotified = mf.getLastModified() * 1000;
|
||||
if (mf.getLocaleFile().setLastModified(lastMotified)) {
|
||||
logger.debug("ZSync - set last motified to {}", lastMotified);
|
||||
} else {
|
||||
logger.debug("ZSync - Failed to set last modified!");
|
||||
}
|
||||
|
||||
finnishCurrent();
|
||||
continue;
|
||||
}
|
||||
@ -268,6 +276,16 @@ public class Syncer implements Observable, SyncListener {
|
||||
final int percentage = (int) ((double) i / (double) Long.valueOf(syncCount).intValue() * 100);
|
||||
final String modPath = currentDownload.getModPath();
|
||||
|
||||
|
||||
if(!currentDownload_failed) {
|
||||
long lastMotified = currentDownload.getLastModified() * 1000;
|
||||
if (currentDownload.getLocaleFile().setLastModified(lastMotified)) {
|
||||
logger.debug("ZSync - set last motified to {}", lastMotified);
|
||||
} else {
|
||||
logger.debug("ZSync - Failed to set last modified!");
|
||||
}
|
||||
}
|
||||
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
gui.syncDownloadProgress.setValue(i);
|
||||
gui.syncFileCountLabel.setText(i + "/" + syncCount + " (" + failed + " failed)");
|
||||
|
Loading…
Reference in New Issue
Block a user