CleanCacheWorker: delete all package files, not just *.apk

The installer can copy OTA .zip, *.obf, etc. there too.

refs #1869
This commit is contained in:
Hans-Christoph Steiner 2021-03-03 12:03:29 +01:00
parent eb6ab1ec0a
commit ce7d241196
3 changed files with 11 additions and 2 deletions

View File

@ -0,0 +1,5 @@
package org.fdroid.fdroid.nearby;
public class LocalRepoManager {
public static final String[] WEB_ROOT_ASSET_FILES = {};
}

View File

@ -64,7 +64,7 @@ public final class LocalRepoManager {
private final AssetManager assetManager;
private final String fdroidPackageName;
private static final String[] WEB_ROOT_ASSET_FILES = {
public static final String[] WEB_ROOT_ASSET_FILES = {
"swap-icon.png",
"swap-tick-done.png",
"swap-tick-not-done.png",

View File

@ -20,8 +20,11 @@ import org.apache.commons.io.FileUtils;
import org.fdroid.fdroid.Preferences;
import org.fdroid.fdroid.Utils;
import org.fdroid.fdroid.installer.ApkCache;
import org.fdroid.fdroid.nearby.LocalRepoManager;
import java.io.File;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.TimeUnit;
/**
@ -127,8 +130,9 @@ public class CleanCacheWorker extends Worker {
return;
}
final List<String> webRootAssetFiles = Arrays.asList(LocalRepoManager.WEB_ROOT_ASSET_FILES);
for (File f : files) {
if (f.getName().endsWith(".apk")) {
if (f.isFile() && !f.getName().endsWith(".html") && !webRootAssetFiles.contains(f.getName())) {
clearOldFiles(f, TimeUnit.HOURS.toMillis(1));
}
}