Skip to content

Commit

Permalink
Add sanity check for missing local gallery video
Browse files Browse the repository at this point in the history
  • Loading branch information
melonmanchan committed Apr 26, 2016
1 parent 5e0d542 commit 72dccdf
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import android.net.Uri;
import android.os.AsyncTask;
import android.support.annotation.NonNull;
import android.webkit.URLUtil;

import com.google.common.io.Files;
import com.rollbar.android.Rollbar;
Expand Down Expand Up @@ -124,6 +125,19 @@ protected Video readVideoFromFile(File file) throws IOException {
video.setManifestUri(Uri.fromFile(file));
video.setLastModified(new Date(file.lastModified()));
video.setRepository(this);

Uri videoUri = video.getVideoUri();

// Sanity test to check if user deleted video file from gallery
// Missing thumb nail icon is fine, since you can still watch the local video
if (URLUtil.isFileUrl(videoUri.toString())) {
File sanityCheckFile = new File(videoUri.getPath());

if (!sanityCheckFile.exists()) {
throw new IOException("Local video file not found at " + videoUri);
}
}

return video;
}

Expand Down

0 comments on commit 72dccdf

Please sign in to comment.