Implement preserve and alias in index

This commit is contained in:
comp500 2019-06-24 17:47:17 +01:00
parent 12bf090895
commit d1647764c4
No known key found for this signature in database
GPG Key ID: 214C822FFEC586B5
2 changed files with 13 additions and 6 deletions

View File

@ -157,10 +157,9 @@ public class UpdateManager {
ui.handleExceptionAndExit(e1);
}
// When successfully updated
// TODO: update MMC params, java args etc
manifest.packFileHash = packFileSource.getHash();
// update other hashes
// TODO: don't do this on failure?
try (Writer writer = new FileWriter(Paths.get(opts.packFolder, opts.manifestFile).toString())) {
gson.toJson(manifest, writer);
} catch (IOException e) {
@ -271,6 +270,13 @@ public class UpdateManager {
} catch (Exception e) {}
}
// Don't update files marked with preserve if they already exist on disk
if (f.preserve) {
if (Files.exists(Paths.get(opts.packFolder, f.getDestURI().toString()))) {
return dc;
}
}
try {
Hash hash;
String fileHashFormat;

View File

@ -26,10 +26,8 @@ public class IndexFile {
@SerializedName("hash-format")
public String hashFormat;
public String hash;
// TODO: implement
public String alias;
public URI alias;
public boolean metafile;
// TODO: implement
public boolean preserve;
public transient ModFile linkedFile;
@ -96,6 +94,9 @@ public class IndexFile {
}
public URI getDestURI() {
if (alias != null) {
return alias;
}
if (metafile && linkedFile != null) {
// TODO: URIs are bad
return file.resolve(linkedFile.filename.replace(" ", "%20"));