From 17628d972016e1d451f61ced3b0d7cdf2669bac6 Mon Sep 17 00:00:00 2001 From: Matti Jokitulppo Date: Tue, 26 Apr 2016 17:01:27 +0300 Subject: [PATCH] Clean up files that have been removed from the local file system --- .../legroup/achso/storage/CombinedVideoRepository.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/src/main/java/fi/aalto/legroup/achso/storage/CombinedVideoRepository.java b/app/src/main/java/fi/aalto/legroup/achso/storage/CombinedVideoRepository.java index 3c200308..b55f1439 100644 --- a/app/src/main/java/fi/aalto/legroup/achso/storage/CombinedVideoRepository.java +++ b/app/src/main/java/fi/aalto/legroup/achso/storage/CombinedVideoRepository.java @@ -134,6 +134,16 @@ protected Video readVideoFromFile(File file) throws IOException { File sanityCheckFile = new File(videoUri.getPath()); if (!sanityCheckFile.exists()) { + + // Also remove thumb file; + File thumbFile = new File(video.getThumbUri().getPath()); + File videoFile = getLocalVideoFile(video.getId()); + + thumbFile.delete(); + videoFile.delete(); + allVideos.remove(video.getId()); + bus.post(new VideoRepositoryUpdatedEvent(this)); + throw new IOException("Local video file not found at " + videoUri); } }