Merge "Restore existing committer info correctly when a new commit fails." into rvc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
60606304b0
@@ -116,7 +116,7 @@ class BlobMetadata {
|
||||
return mUserId;
|
||||
}
|
||||
|
||||
void addCommitter(@NonNull Committer committer) {
|
||||
void addOrReplaceCommitter(@NonNull Committer committer) {
|
||||
synchronized (mMetadataLock) {
|
||||
// We need to override the committer data, so first remove any existing
|
||||
// committer before adding the new one.
|
||||
@@ -139,6 +139,12 @@ class BlobMetadata {
|
||||
}
|
||||
}
|
||||
|
||||
void removeCommitter(@NonNull Committer committer) {
|
||||
synchronized (mMetadataLock) {
|
||||
mCommitters.remove(committer);
|
||||
}
|
||||
}
|
||||
|
||||
void removeInvalidCommitters(SparseArray<String> packages) {
|
||||
synchronized (mMetadataLock) {
|
||||
mCommitters.removeIf(committer ->
|
||||
@@ -154,7 +160,7 @@ class BlobMetadata {
|
||||
}
|
||||
}
|
||||
|
||||
void addLeasee(String callingPackage, int callingUid, int descriptionResId,
|
||||
void addOrReplaceLeasee(String callingPackage, int callingUid, int descriptionResId,
|
||||
CharSequence description, long leaseExpiryTimeMillis) {
|
||||
synchronized (mMetadataLock) {
|
||||
// We need to override the leasee data, so first remove any existing
|
||||
|
||||
@@ -401,7 +401,7 @@ public class BlobStoreManagerService extends SystemService {
|
||||
throw new LimitExceededException("Total amount of data with an active lease"
|
||||
+ " is exceeding the max limit");
|
||||
}
|
||||
blobMetadata.addLeasee(callingPackage, callingUid,
|
||||
blobMetadata.addOrReplaceLeasee(callingPackage, callingUid,
|
||||
descriptionResId, description, leaseExpiryTimeMillis);
|
||||
if (LOGV) {
|
||||
Slog.v(TAG, "Acquired lease on " + blobHandle
|
||||
@@ -573,12 +573,16 @@ public class BlobStoreManagerService extends SystemService {
|
||||
final Committer newCommitter = new Committer(session.getOwnerPackageName(),
|
||||
session.getOwnerUid(), session.getBlobAccessMode());
|
||||
final Committer existingCommitter = blob.getExistingCommitter(newCommitter);
|
||||
blob.addCommitter(newCommitter);
|
||||
blob.addOrReplaceCommitter(newCommitter);
|
||||
try {
|
||||
writeBlobsInfoLocked();
|
||||
session.sendCommitCallbackResult(COMMIT_RESULT_SUCCESS);
|
||||
} catch (Exception e) {
|
||||
blob.addCommitter(existingCommitter);
|
||||
if (existingCommitter == null) {
|
||||
blob.removeCommitter(newCommitter);
|
||||
} else {
|
||||
blob.addOrReplaceCommitter(existingCommitter);
|
||||
}
|
||||
session.sendCommitCallbackResult(COMMIT_RESULT_ERROR);
|
||||
}
|
||||
getUserSessionsLocked(UserHandle.getUserId(session.getOwnerUid()))
|
||||
|
||||
Reference in New Issue
Block a user