Include an images full URL in the cache path.
All feature graphics are called `featureGraphic.png`, and so our cache was presuming all feature graphics were the same image. By including the full path from the server in the cached name, we don't overwrite images any more.
This commit is contained in:
parent
bd5503b4cd
commit
67a29bae8f
@ -54,6 +54,7 @@ import org.fdroid.fdroid.compat.PRNGFixes;
|
||||
import org.fdroid.fdroid.data.AppProvider;
|
||||
import org.fdroid.fdroid.data.InstalledAppProviderService;
|
||||
import org.fdroid.fdroid.data.Repo;
|
||||
import org.fdroid.fdroid.data.SanitizedFile;
|
||||
import org.fdroid.fdroid.installer.InstallHistoryService;
|
||||
import org.fdroid.fdroid.net.ImageLoaderForUIL;
|
||||
import org.fdroid.fdroid.net.WifiStateChangeService;
|
||||
@ -282,7 +283,7 @@ public class FDroidApp extends Application {
|
||||
if (TextUtils.isEmpty(imageUri)) {
|
||||
return "null";
|
||||
} else {
|
||||
return imageUri.substring(imageUri.lastIndexOf('/') + 1);
|
||||
return SanitizedFile.sanitizeFileName(Uri.parse(imageUri).getPath().replaceAll("/", "-"));
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -11,13 +11,20 @@ import java.io.File;
|
||||
@SuppressWarnings("serial")
|
||||
public class SanitizedFile extends File {
|
||||
|
||||
/**
|
||||
* Removes anything that is not an alpha numeric character, or one of "-", ".", or "_".
|
||||
*/
|
||||
public static String sanitizeFileName(String name) {
|
||||
return name.replaceAll("[^A-Za-z0-9-._]", "");
|
||||
}
|
||||
|
||||
/**
|
||||
* The "name" argument is assumed to be a file name, _not including any path separators_.
|
||||
* If it is a relative path to be appended to "parent", such as "/blah/sneh.txt", then
|
||||
* the forward slashes will be removed and it will be assumed you meant "blahsneh.txt".
|
||||
*/
|
||||
public SanitizedFile(File parent, String name) {
|
||||
super(parent, name.replaceAll("[^A-Za-z0-9-._]", ""));
|
||||
super(parent, sanitizeFileName(name));
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user