This commit is contained in:
parent
a794f1daff
commit
32237f57ef
|
@ -163,7 +163,6 @@ public class LibraryManager
|
|||
Artifact artifact = ret.getLeft();
|
||||
Repository repo = modlist.getRepository() == null ? libraries_dir : modlist.getRepository();
|
||||
File moved = repo.archive(artifact, file, ret.getRight());
|
||||
modlist.add(artifact);
|
||||
processed.add(moved);
|
||||
}
|
||||
}
|
||||
|
@ -213,9 +212,9 @@ public class LibraryManager
|
|||
if (jar.getManifest() == null)
|
||||
return null;
|
||||
|
||||
JarEntry manfest_entry = jar.getJarEntry(JarFile.MANIFEST_NAME);
|
||||
if (manfest_entry == null)
|
||||
manfest_entry = jar.stream().filter(e -> JarFile.MANIFEST_NAME.equals(e.getName().toUpperCase(Locale.ENGLISH))).findFirst().get(); //We know that getManifest returned non-null so we know there is *some* entry that matches the manifest file. So we dont need to empty check.
|
||||
JarEntry manifest_entry = jar.getJarEntry(JarFile.MANIFEST_NAME);
|
||||
if (manifest_entry == null)
|
||||
manifest_entry = jar.stream().filter(e -> JarFile.MANIFEST_NAME.equals(e.getName().toUpperCase(Locale.ENGLISH))).findFirst().get(); //We know that getManifest returned non-null so we know there is *some* entry that matches the manifest file. So we dont need to empty check.
|
||||
|
||||
attrs = jar.getManifest().getMainAttributes();
|
||||
|
||||
|
@ -318,14 +317,16 @@ public class LibraryManager
|
|||
{
|
||||
try
|
||||
{
|
||||
String timestamp = meta.getValue(TIMESTAMP);
|
||||
if (timestamp != null)
|
||||
timestamp = SnapshotJson.TIMESTAMP.format(new Date(Long.parseLong(timestamp)));
|
||||
|
||||
Artifact artifact = new Artifact(modlist.getRepository(), meta.getValue(MAVEN_ARTIFACT), timestamp);
|
||||
Artifact artifact = readArtifact(modlist.getRepository(), meta);
|
||||
File target = artifact.getFile();
|
||||
if (target.exists())
|
||||
{
|
||||
FMLLog.log.debug("Found existing ContainedDep {}({}) from {} extracted to {}, skipping extraction", dep, artifact.toString(), target.getCanonicalPath(), jar.getName());
|
||||
if (!ENABLE_AUTO_MOD_MOVEMENT)
|
||||
{
|
||||
extractPacked(target, modlist, modDirs); //If we're not building a real list we have to re-build the dep list every run. So search down.
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
FMLLog.log.debug("Extracting ContainedDep {}({}) from {} to {}", dep, artifact.toString(), jar.getName(), target.getCanonicalPath());
|
||||
|
@ -367,7 +368,22 @@ public class LibraryManager
|
|||
}
|
||||
}
|
||||
|
||||
return attrs.containsKey(MAVEN_ARTIFACT) ? Pair.of(new Artifact(modlist.getRepository(), attrs.getValue(MAVEN_ARTIFACT), attrs.getValue(TIMESTAMP)), readAll(jar.getInputStream(manfest_entry))) : null;
|
||||
if (attrs.containsKey(MAVEN_ARTIFACT))
|
||||
{
|
||||
Artifact artifact = readArtifact(modlist.getRepository(), attrs);
|
||||
modlist.add(artifact);
|
||||
return Pair.of(artifact, readAll(jar.getInputStream(manifest_entry)));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static Artifact readArtifact(Repository repo, Attributes meta)
|
||||
{
|
||||
String timestamp = meta.getValue(TIMESTAMP);
|
||||
if (timestamp != null)
|
||||
timestamp = SnapshotJson.TIMESTAMP.format(new Date(Long.parseLong(timestamp)));
|
||||
|
||||
return new Artifact(repo, meta.getValue(MAVEN_ARTIFACT), timestamp);
|
||||
}
|
||||
|
||||
private static byte[] readAll(InputStream in) throws IOException
|
||||
|
|
|
@ -90,13 +90,13 @@ public class LinkRepository extends Repository
|
|||
String key = artifact.toString();
|
||||
File file = artifact_to_file.get(key);
|
||||
if (file == null || !file.exists())
|
||||
return null;
|
||||
return super.resolve(artifact);
|
||||
return new Artifact(artifact, this, artifact.isSnapshot() ? artifact.getTimestamp() : null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getFile(String path)
|
||||
{
|
||||
return filesystem.containsKey(path) ? super.getFile(path) : filesystem.get(path);
|
||||
return filesystem.containsKey(path) ? filesystem.get(path) : super.getFile(path);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -174,6 +174,7 @@ public class ModList
|
|||
}
|
||||
else
|
||||
artifacts.add(artifact);
|
||||
art_map.put(artifact.toString(), artifact);
|
||||
changed = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -40,21 +40,21 @@ import net.minecraftforge.fml.common.FMLLog;
|
|||
* So we JUST use the timestamp.
|
||||
*
|
||||
* {
|
||||
* "latest": "yyyymmdd.hhmmss",
|
||||
* "latest": "yyyyMMdd.hhmmss",
|
||||
* "versions": [
|
||||
* {
|
||||
* "md5": "md5 in hex lowercase",
|
||||
* "timestamp": "yyyymmdd.hhmmss"
|
||||
* "timestamp": "yyyyMMdd.hhmmss"
|
||||
* ]
|
||||
* }
|
||||
*
|
||||
*/
|
||||
public class SnapshotJson implements Comparable<SnapshotJson>
|
||||
{
|
||||
public static final DateFormat TIMESTAMP = new SimpleDateFormat("yyyymmdd.hhmmss");
|
||||
public static final DateFormat TIMESTAMP = new SimpleDateFormat("yyyyMMdd.hhmmss");
|
||||
public static final String META_JSON_FILE = "maven-metadata.json";
|
||||
private static final Gson GSON = new GsonBuilder().create();
|
||||
private static final Comparator<Entry> SORTER = (o1, o2) -> o2.timestamp.compareTo(o2.timestamp);
|
||||
private static final Comparator<Entry> SORTER = (o1, o2) -> o2.timestamp.compareTo(o1.timestamp);
|
||||
|
||||
public static SnapshotJson create(File target)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue