mirror of
https://github.com/oxen-io/session-android.git
synced 2025-06-09 03:48:34 +00:00
Remove unused pictures that were captured outside of the in-app camera.
This commit is contained in:
parent
72c14b8651
commit
7bb1caa22e
@ -18,6 +18,7 @@ import org.thoughtcrime.securesms.jobmanager.migrations.RecipientIdFollowUpJobMi
|
|||||||
import org.thoughtcrime.securesms.jobmanager.migrations.RecipientIdFollowUpJobMigration2;
|
import org.thoughtcrime.securesms.jobmanager.migrations.RecipientIdFollowUpJobMigration2;
|
||||||
import org.thoughtcrime.securesms.jobmanager.migrations.RecipientIdJobMigration;
|
import org.thoughtcrime.securesms.jobmanager.migrations.RecipientIdJobMigration;
|
||||||
import org.thoughtcrime.securesms.migrations.AvatarMigrationJob;
|
import org.thoughtcrime.securesms.migrations.AvatarMigrationJob;
|
||||||
|
import org.thoughtcrime.securesms.migrations.CachedAttachmentsMigrationJob;
|
||||||
import org.thoughtcrime.securesms.migrations.DatabaseMigrationJob;
|
import org.thoughtcrime.securesms.migrations.DatabaseMigrationJob;
|
||||||
import org.thoughtcrime.securesms.migrations.LegacyMigrationJob;
|
import org.thoughtcrime.securesms.migrations.LegacyMigrationJob;
|
||||||
import org.thoughtcrime.securesms.migrations.MigrationCompleteJob;
|
import org.thoughtcrime.securesms.migrations.MigrationCompleteJob;
|
||||||
@ -90,6 +91,7 @@ public final class JobManagerFactories {
|
|||||||
put(MigrationCompleteJob.KEY, new MigrationCompleteJob.Factory());
|
put(MigrationCompleteJob.KEY, new MigrationCompleteJob.Factory());
|
||||||
put(RecipientSearchMigrationJob.KEY, new RecipientSearchMigrationJob.Factory());
|
put(RecipientSearchMigrationJob.KEY, new RecipientSearchMigrationJob.Factory());
|
||||||
put(UuidMigrationJob.KEY, new UuidMigrationJob.Factory());
|
put(UuidMigrationJob.KEY, new UuidMigrationJob.Factory());
|
||||||
|
put(CachedAttachmentsMigrationJob.KEY, new CachedAttachmentsMigrationJob.Factory());
|
||||||
|
|
||||||
// Dead jobs
|
// Dead jobs
|
||||||
put("PushContentReceiveJob", new FailingJob.Factory());
|
put("PushContentReceiveJob", new FailingJob.Factory());
|
||||||
|
@ -38,15 +38,16 @@ public class ApplicationMigrations {
|
|||||||
|
|
||||||
private static final int LEGACY_CANONICAL_VERSION = 455;
|
private static final int LEGACY_CANONICAL_VERSION = 455;
|
||||||
|
|
||||||
public static final int CURRENT_VERSION = 6;
|
public static final int CURRENT_VERSION = 7;
|
||||||
|
|
||||||
private static final class Version {
|
private static final class Version {
|
||||||
static final int LEGACY = 1;
|
static final int LEGACY = 1;
|
||||||
static final int RECIPIENT_ID = 2;
|
static final int RECIPIENT_ID = 2;
|
||||||
static final int RECIPIENT_SEARCH = 3;
|
static final int RECIPIENT_SEARCH = 3;
|
||||||
static final int RECIPIENT_CLEANUP = 4;
|
static final int RECIPIENT_CLEANUP = 4;
|
||||||
static final int AVATAR_MIGRATION = 5;
|
static final int AVATAR_MIGRATION = 5;
|
||||||
static final int UUIDS = 6;
|
static final int UUIDS = 6;
|
||||||
|
static final int CACHED_ATTACHMENTS = 7;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -183,6 +184,10 @@ public class ApplicationMigrations {
|
|||||||
jobs.put(Version.UUIDS, new UuidMigrationJob());
|
jobs.put(Version.UUIDS, new UuidMigrationJob());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (lastSeenVersion < Version.CACHED_ATTACHMENTS) {
|
||||||
|
jobs.put(Version.CACHED_ATTACHMENTS, new CachedAttachmentsMigrationJob());
|
||||||
|
}
|
||||||
|
|
||||||
return jobs;
|
return jobs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user