Clean up the nresource patch & older code cache stuff.

Two important changes:

1. Don't change the name of the code cache dir as that would leave a stale code
cache around on old installations that were using the code cache.

2. Don't create a native libs cache dir if there are no native resources.

Everything else is mostly cosmetic and organizational.
This commit is contained in:
Michael Bayne
2018-12-06 11:44:29 -08:00
parent 20fd43fd98
commit 16b8b836e4
13 changed files with 239 additions and 281 deletions
@@ -1,4 +1,9 @@
package com.threerings.getdown.classpath.cache;
//
// Getdown - application installer, patcher and launcher
// Copyright (C) 2004-2016 Getdown authors
// https://github.com/threerings/getdown/blob/master/LICENSE
package com.threerings.getdown.cache;
import java.io.File;
import java.io.IOException;
@@ -1,4 +1,9 @@
package com.threerings.getdown.classpath.cache;
//
// Getdown - application installer, patcher and launcher
// Copyright (C) 2004-2016 Getdown authors
// https://github.com/threerings/getdown/blob/master/LICENSE
package com.threerings.getdown.cache;
import java.io.File;
import java.io.IOException;
@@ -26,7 +31,7 @@ public class ResourceCacheTest
private File cacheFile() throws IOException
{
return _cache.cacheFile(_fileToCache, "abc123");
return _cache.cacheFile(_fileToCache, "abc123", "abc123");
}
@Test public void shouldTrackFileUsage () throws IOException
@@ -1,4 +1,9 @@
package com.threerings.getdown.classpath;
//
// Getdown - application installer, patcher and launcher
// Copyright (C) 2004-2016 Getdown authors
// https://github.com/threerings/getdown/blob/master/LICENSE
package com.threerings.getdown.data;
import java.io.File;
import java.io.IOException;
@@ -1,4 +1,9 @@
package com.threerings.getdown.classpath;
//
// Getdown - application installer, patcher and launcher
// Copyright (C) 2004-2016 Getdown authors
// https://github.com/threerings/getdown/blob/master/LICENSE
package com.threerings.getdown.data;
import java.io.File;
import java.io.IOException;
@@ -14,11 +19,8 @@ import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import static org.mockito.Mockito.when;
import com.threerings.getdown.data.Application;
import com.threerings.getdown.data.Resource;
@RunWith(MockitoJUnitRunner.class)
public class ClassPathsTest
public class PathBuilderTest
{
@Before public void setupFilesAndResources () throws IOException
{
@@ -33,7 +35,7 @@ public class ClassPathsTest
@Test public void shouldBuildDefaultClassPath () throws IOException
{
ClassPath classPath = ClassPaths.buildDefaultClassPath(_application);
ClassPath classPath = PathBuilder.buildDefaultClassPath(_application);
String expectedClassPath = _firstJarFile.getAbsolutePath() + File.pathSeparator +
_secondJarFile.getAbsolutePath();
assertEquals(expectedClassPath, classPath.asArgumentString());
@@ -46,15 +48,15 @@ public class ClassPathsTest
when(_application.getCodeCacheRetentionDays()).thenReturn(1);
Path firstCachedJarFile = _appdir.getRoot().toPath().
resolve(Application.CACHE_DIR + "/code").resolve("fi").resolve("first.jar");
resolve(PathBuilder.CODE_CACHE_DIR).resolve("fi").resolve("first.jar");
Path secondCachedJarFile = _appdir.getRoot().toPath().
resolve(Application.CACHE_DIR + "/code").resolve("se").resolve("second.jar");
resolve(PathBuilder.CODE_CACHE_DIR).resolve("se").resolve("second.jar");
String expectedClassPath = firstCachedJarFile.toAbsolutePath() + File.pathSeparator +
secondCachedJarFile.toAbsolutePath();
ClassPath classPath = ClassPaths.buildCachedClassPath(_application);
ClassPath classPath = PathBuilder.buildCachedClassPath(_application);
assertEquals(expectedClassPath, classPath.asArgumentString());
}