/** * Deletes this temporary {@link AssetBlob} by clearing any locally ingested blobs. * * Note this shouldn't stop the current response from serving back temporary content, * it just makes sure non-persisted content is eventually cleaned up from the store. * * @since 3.4 */ void delete(final String reason) { if (ingestedBlob != null) { if (canonicalBlob != null) { // canonical redirect is in place, so it's safe to hard-delete the temp blob blobStore.deleteHard(ingestedBlob.getId()); } else { // no redirect, so the temp blob is all we have - use soft-delete so the bytes // will still be available on disk for streaming back in the current response, // while making sure it gets cleaned up on the next compact blobStore.delete(ingestedBlob.getId(), reason); } } }
public void commit() { for (Entry<BlobRef, String> deletionRequestEntry : deletionRequests.entrySet()) { try { blobStore.delete(deletionRequestEntry.getKey().getBlobId(), deletionRequestEntry.getValue()); } catch (Throwable t) { log.warn("Unable to delete old blob {} while committing transaction", deletionRequestEntry.getKey(), t); } } for (AssetBlob assetBlob : newlyCreatedBlobs) { try { if (!assetBlob.isAttached()) { assetBlob.delete("Removing unattached asset"); } } catch (Throwable t) { log.warn("Unable to delete new orphan blob {} while committing transaction", assetBlob.getBlobRef(), t); } } clearState(); }
private void deleteBlob(final Set<String> deletedBlobStores, final BlobRef blobRef) { String blobStoreName = blobRef.getStore(); if (deletedBlobStores.contains(blobStoreName)) { return; } BlobStore blobStore = blobStoreManager.get(blobRef.getStore()); if (blobStore == null) { if (deletedBlobStores.add(blobStoreName)) { log.info("Not deleting blobs for blob store {}, blob store not found", blobStoreName); } return; } try { blobStore.delete(blobRef.getBlobId(), "Deleting Bucket"); } catch (InvalidStateException e) { if (deletedBlobStores.add(blobStoreName)) { log.info("Not deleting blobs for blob store {}, invalid state {}", blobStoreName, e.getInvalidState(), log.isDebugEnabled() ? e : null); } } catch (Exception e) { log.warn("Error deleting blob {}, skipping", blobRef, e); } } }