-
-
Notifications
You must be signed in to change notification settings - Fork 6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove unused pictures that were captured outside of the in-app camera.
- Loading branch information
1 parent
72c14b8
commit 7bb1caa
Showing
3 changed files
with
80 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
src/org/thoughtcrime/securesms/migrations/CachedAttachmentsMigrationJob.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package org.thoughtcrime.securesms.migrations; | ||
|
||
import androidx.annotation.NonNull; | ||
|
||
import org.thoughtcrime.securesms.jobmanager.Data; | ||
import org.thoughtcrime.securesms.jobmanager.Job; | ||
import org.thoughtcrime.securesms.logging.Log; | ||
import org.thoughtcrime.securesms.mms.GlideApp; | ||
import org.thoughtcrime.securesms.util.FileUtils; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
|
||
public class CachedAttachmentsMigrationJob extends MigrationJob { | ||
|
||
private static final String TAG = Log.tag(CachedAttachmentsMigrationJob.class); | ||
|
||
public static final String KEY = "CachedAttachmentsMigrationJob"; | ||
|
||
CachedAttachmentsMigrationJob() { | ||
this(new Parameters.Builder().build()); | ||
} | ||
|
||
private CachedAttachmentsMigrationJob(@NonNull Parameters parameters) { | ||
super(parameters); | ||
} | ||
|
||
@Override | ||
boolean isUiBlocking() { | ||
return false; | ||
} | ||
|
||
@Override | ||
void performMigration() { | ||
File externalCacheDir = context.getExternalCacheDir(); | ||
|
||
if (externalCacheDir == null || !externalCacheDir.exists() || !externalCacheDir.isDirectory()) { | ||
Log.w(TAG, "External Cache Directory either does not exist or isn't a directory. Skipping."); | ||
return; | ||
} | ||
|
||
try { | ||
FileUtils.deleteDirectoryContents(context.getExternalCacheDir()); | ||
GlideApp.get(context).clearDiskCache(); | ||
} catch (IOException e) { | ||
Log.w(TAG, e); | ||
} | ||
} | ||
|
||
@Override | ||
boolean shouldRetry(@NonNull Exception e) { | ||
return false; | ||
} | ||
|
||
@Override | ||
public @NonNull String getFactoryKey() { | ||
return KEY; | ||
} | ||
|
||
public static class Factory implements Job.Factory<CachedAttachmentsMigrationJob> { | ||
@Override | ||
public @NonNull CachedAttachmentsMigrationJob create(@NonNull Parameters parameters, @NonNull Data data) { | ||
return new CachedAttachmentsMigrationJob(parameters); | ||
} | ||
} | ||
} |