kopia lustrzana https://github.com/ryukoposting/Signal-Android
Fix initialization of BlobProvider.
rodzic
55a62ead05
commit
fb98874948
|
@ -172,7 +172,7 @@ public class BlobProvider {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.d(TAG, "Deleting " + uri);
|
Log.d(TAG, "Deleting " + getId(uri));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
StorageType storageType = StorageType.decode(uri.getPathSegments().get(STORAGE_TYPE_PATH_SEGMENT));
|
StorageType storageType = StorageType.decode(uri.getPathSegments().get(STORAGE_TYPE_PATH_SEGMENT));
|
||||||
|
@ -185,13 +185,13 @@ public class BlobProvider {
|
||||||
File file = new File(getOrCreateDirectory(context, directory), buildFileName(id));
|
File file = new File(getOrCreateDirectory(context, directory), buildFileName(id));
|
||||||
|
|
||||||
if (file.delete()) {
|
if (file.delete()) {
|
||||||
Log.d(TAG, "Successfully deleted " + uri);
|
Log.d(TAG, "Successfully deleted " + getId(uri));
|
||||||
} else {
|
} else {
|
||||||
throw new IOException("File wasn't deleted.");
|
throw new IOException("File wasn't deleted.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.w(TAG, "Failed to delete uri: " + uri, e);
|
Log.w(TAG, "Failed to delete uri: " + getId(uri), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -203,6 +203,7 @@ public class BlobProvider {
|
||||||
@AnyThread
|
@AnyThread
|
||||||
public synchronized void initialize(@NonNull Context context) {
|
public synchronized void initialize(@NonNull Context context) {
|
||||||
SignalExecutors.BOUNDED.execute(() -> {
|
SignalExecutors.BOUNDED.execute(() -> {
|
||||||
|
synchronized (this) {
|
||||||
File directory = getOrCreateDirectory(context, SINGLE_SESSION_DIRECTORY);
|
File directory = getOrCreateDirectory(context, SINGLE_SESSION_DIRECTORY);
|
||||||
File[] files = directory.listFiles();
|
File[] files = directory.listFiles();
|
||||||
|
|
||||||
|
@ -218,7 +219,10 @@ public class BlobProvider {
|
||||||
Log.w(TAG, "Null directory listing!");
|
Log.w(TAG, "Null directory listing!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Log.i(TAG, "Initialized.");
|
||||||
initialized = true;
|
initialized = true;
|
||||||
|
notifyAll();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -247,6 +251,13 @@ public class BlobProvider {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static @Nullable String getId(@NonNull Uri uri) {
|
||||||
|
if (isAuthority(uri)) {
|
||||||
|
return uri.getPathSegments().get(ID_PATH_SEGMENT);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@WorkerThread
|
@WorkerThread
|
||||||
public long calculateFileSize(@NonNull Context context, @NonNull Uri uri) {
|
public long calculateFileSize(@NonNull Context context, @NonNull Uri uri) {
|
||||||
if (!isAuthority(uri)) {
|
if (!isAuthority(uri)) {
|
||||||
|
@ -269,6 +280,8 @@ public class BlobProvider {
|
||||||
private synchronized @NonNull Uri writeBlobSpecToDisk(@NonNull Context context, @NonNull BlobSpec blobSpec)
|
private synchronized @NonNull Uri writeBlobSpecToDisk(@NonNull Context context, @NonNull BlobSpec blobSpec)
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
|
waitUntilInitialized();
|
||||||
|
|
||||||
CountDownLatch latch = new CountDownLatch(1);
|
CountDownLatch latch = new CountDownLatch(1);
|
||||||
AtomicReference<IOException> exception = new AtomicReference<>(null);
|
AtomicReference<IOException> exception = new AtomicReference<>(null);
|
||||||
Uri uri = writeBlobSpecToDiskAsync(context, blobSpec, latch::countDown, e -> {
|
Uri uri = writeBlobSpecToDiskAsync(context, blobSpec, latch::countDown, e -> {
|
||||||
|
|
Ładowanie…
Reference in New Issue