mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-24 08:47:46 +00:00
fix direct capture file writing race condition
fixes #4612 Closes #4634 // FREEBIE
This commit is contained in:
parent
3bfb123b33
commit
a04e737526
@ -1351,7 +1351,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
|
||||
@Override
|
||||
public void onImageCapture(@NonNull final byte[] imageBytes) {
|
||||
setMedia(PersistentBlobProvider.getInstance(this).create(masterSecret, recipients, imageBytes), MediaType.IMAGE);
|
||||
setMedia(PersistentBlobProvider.getInstance(this).create(masterSecret, imageBytes), MediaType.IMAGE);
|
||||
quickAttachmentDrawer.hide(false);
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,6 @@ import android.content.ContentUris;
|
||||
import android.content.Context;
|
||||
import android.content.UriMatcher;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.util.Log;
|
||||
|
||||
@ -61,10 +60,9 @@ public class PersistentBlobProvider {
|
||||
}
|
||||
|
||||
public Uri create(@NonNull MasterSecret masterSecret,
|
||||
@NonNull Recipients recipients,
|
||||
@NonNull byte[] imageBytes)
|
||||
{
|
||||
final long id = generateId(recipients);
|
||||
final long id = System.currentTimeMillis();
|
||||
cache.put(id, imageBytes);
|
||||
return create(masterSecret, new ByteArrayInputStream(imageBytes), id);
|
||||
}
|
||||
@ -108,8 +106,12 @@ public class PersistentBlobProvider {
|
||||
|
||||
public boolean delete(@NonNull Uri uri) {
|
||||
switch (MATCHER.match(uri)) {
|
||||
case MATCH: return getFile(ContentUris.parseId(uri)).delete();
|
||||
default: return new File(uri.getPath()).delete();
|
||||
case MATCH:
|
||||
long id = ContentUris.parseId(uri);
|
||||
cache.remove(id);
|
||||
return getFile(ContentUris.parseId(uri)).delete();
|
||||
default:
|
||||
return new File(uri.getPath()).delete();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user