mirror of
https://github.com/packwiz/packwiz-installer.git
synced 2025-04-19 21:16:30 +02:00
Handle renamed files correctly, log invalidation
This commit is contained in:
parent
780efe2c9f
commit
34a86ffb7d
@ -230,6 +230,7 @@ public class UpdateManager {
|
|||||||
}
|
}
|
||||||
it.remove();
|
it.remove();
|
||||||
} else if (!Files.exists(filePath)) {
|
} else if (!Files.exists(filePath)) {
|
||||||
|
System.out.println("File " + fileUri.toString() + " invalidated, marked for redownloading");
|
||||||
invalidatedUris.add(fileUri);
|
invalidatedUris.add(fileUri);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -302,9 +303,11 @@ public class UpdateManager {
|
|||||||
} catch (Exception e) {}
|
} catch (Exception e) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Path destPath = Paths.get(opts.packFolder, f.getDestURI().toString());
|
||||||
|
|
||||||
// Don't update files marked with preserve if they already exist on disk
|
// Don't update files marked with preserve if they already exist on disk
|
||||||
if (f.preserve) {
|
if (f.preserve) {
|
||||||
if (Files.exists(Paths.get(opts.packFolder, f.getDestURI().toString()))) {
|
if (Files.exists(destPath)) {
|
||||||
return dc;
|
return dc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -326,8 +329,8 @@ public class UpdateManager {
|
|||||||
Okio.buffer(fileSource).readAll(data);
|
Okio.buffer(fileSource).readAll(data);
|
||||||
|
|
||||||
if (fileSource.hashIsEqual(hash)) {
|
if (fileSource.hashIsEqual(hash)) {
|
||||||
Files.createDirectories(Paths.get(opts.packFolder, f.getDestURI().toString()).getParent());
|
Files.createDirectories(destPath.getParent());
|
||||||
Files.copy(data.inputStream(), Paths.get(opts.packFolder, f.getDestURI().toString()), StandardCopyOption.REPLACE_EXISTING);
|
Files.copy(data.inputStream(), destPath, StandardCopyOption.REPLACE_EXISTING);
|
||||||
} else {
|
} else {
|
||||||
System.out.println("Invalid hash for " + f.getDestURI().toString());
|
System.out.println("Invalid hash for " + f.getDestURI().toString());
|
||||||
System.out.println("Calculated: " + fileSource.getHash());
|
System.out.println("Calculated: " + fileSource.getHash());
|
||||||
@ -335,6 +338,11 @@ public class UpdateManager {
|
|||||||
dc.err = new Exception("Hash invalid!");
|
dc.err = new Exception("Hash invalid!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cachedFile != null && !destPath.equals(Paths.get(opts.packFolder, cachedFile.cachedLocation))) {
|
||||||
|
// Delete old file if location changes
|
||||||
|
Files.delete(Paths.get(opts.packFolder, cachedFile.cachedLocation));
|
||||||
|
}
|
||||||
|
|
||||||
return dc;
|
return dc;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
dc.err = e;
|
dc.err = e;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user