Delete cached box art when deleting a PC

This commit is contained in:
Cameron Gutman 2019-07-27 16:45:01 -04:00
parent 8665fe364f
commit 352b6f7dd9
2 changed files with 13 additions and 0 deletions

View File

@ -9,6 +9,7 @@ import com.limelight.binding.crypto.AndroidCryptoProvider;
import com.limelight.computers.ComputerManagerListener;
import com.limelight.computers.ComputerManagerService;
import com.limelight.grid.PcGridAdapter;
import com.limelight.grid.assets.DiskAssetLoader;
import com.limelight.nvstream.http.ComputerDetails;
import com.limelight.nvstream.http.NvApp;
import com.limelight.nvstream.http.NvHTTP;
@ -631,6 +632,8 @@ public class PcView extends Activity implements AdapterFragmentCallbacks {
private void removeComputer(ComputerDetails details) {
managerBinder.removeComputer(details);
new DiskAssetLoader(this).deleteAssetsForComputer(details.uuid);
for (int i = 0; i < pcGridAdapter.getCount(); i++) {
ComputerObject computer = (ComputerObject) pcGridAdapter.getItem(i);

View File

@ -137,6 +137,16 @@ public class DiskAssetLoader {
return CacheHelper.openPath(false, cacheDir, "boxart", computerUuid, appId + ".png");
}
public void deleteAssetsForComputer(String computerUuid) {
File dir = CacheHelper.openPath(false, cacheDir, "boxart", computerUuid);
File[] files = dir.listFiles();
if (files != null) {
for (File f : files) {
f.delete();
}
}
}
public void populateCacheWithStream(CachedAppAssetLoader.LoaderTuple tuple, InputStream input) {
OutputStream out = null;
boolean success = false;