forked from Qortal/qortal
Don't delete metadata when deleting a resource from the Data Management screen.
This commit is contained in:
parent
e598d7476b
commit
7deb9328fa
@ -592,7 +592,7 @@ public class ArbitraryResource {
|
|||||||
|
|
||||||
Security.checkApiCallAllowed(request);
|
Security.checkApiCallAllowed(request);
|
||||||
ArbitraryDataResource resource = new ArbitraryDataResource(name, ResourceIdType.NAME, service, identifier);
|
ArbitraryDataResource resource = new ArbitraryDataResource(name, ResourceIdType.NAME, service, identifier);
|
||||||
return resource.delete();
|
return resource.delete(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
|
@ -388,12 +388,15 @@ public class ArbitraryDataFile {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean deleteAll() {
|
public boolean deleteAll(boolean deleteMetadata) {
|
||||||
// Delete the complete file
|
// Delete the complete file
|
||||||
boolean fileDeleted = this.delete();
|
boolean fileDeleted = this.delete();
|
||||||
|
|
||||||
// Delete the metadata file
|
// Delete the metadata file if requested
|
||||||
boolean metadataDeleted = this.deleteMetadata();
|
boolean metadataDeleted = false;
|
||||||
|
if (deleteMetadata) {
|
||||||
|
metadataDeleted = this.deleteMetadata();
|
||||||
|
}
|
||||||
|
|
||||||
// Delete the individual chunks
|
// Delete the individual chunks
|
||||||
boolean chunksDeleted = this.deleteAllChunks();
|
boolean chunksDeleted = this.deleteAllChunks();
|
||||||
|
@ -140,7 +140,7 @@ public class ArbitraryDataResource {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean delete() {
|
public boolean delete(boolean deleteMetadata) {
|
||||||
try {
|
try {
|
||||||
this.fetchTransactions();
|
this.fetchTransactions();
|
||||||
if (this.transactions == null) {
|
if (this.transactions == null) {
|
||||||
@ -157,7 +157,7 @@ public class ArbitraryDataResource {
|
|||||||
arbitraryDataFile.setMetadataHash(metadataHash);
|
arbitraryDataFile.setMetadataHash(metadataHash);
|
||||||
|
|
||||||
// Delete any chunks or complete files from each transaction
|
// Delete any chunks or complete files from each transaction
|
||||||
arbitraryDataFile.deleteAll();
|
arbitraryDataFile.deleteAll(deleteMetadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Also delete cached data for the entire resource
|
// Also delete cached data for the entire resource
|
||||||
|
@ -281,7 +281,7 @@ public class ArbitraryDataTransactionBuilder {
|
|||||||
|
|
||||||
} catch (DataException e) {
|
} catch (DataException e) {
|
||||||
if (arbitraryDataFile != null) {
|
if (arbitraryDataFile != null) {
|
||||||
arbitraryDataFile.deleteAll();
|
arbitraryDataFile.deleteAll(true);
|
||||||
}
|
}
|
||||||
throw(e);
|
throw(e);
|
||||||
}
|
}
|
||||||
@ -315,7 +315,7 @@ public class ArbitraryDataTransactionBuilder {
|
|||||||
|
|
||||||
Transaction.ValidationResult result = transaction.isValidUnconfirmed();
|
Transaction.ValidationResult result = transaction.isValidUnconfirmed();
|
||||||
if (result != Transaction.ValidationResult.OK) {
|
if (result != Transaction.ValidationResult.OK) {
|
||||||
arbitraryDataFile.deleteAll();
|
arbitraryDataFile.deleteAll(true);
|
||||||
throw new DataException(String.format("Arbitrary transaction invalid: %s", result));
|
throw new DataException(String.format("Arbitrary transaction invalid: %s", result));
|
||||||
}
|
}
|
||||||
LOGGER.info("Transaction is valid");
|
LOGGER.info("Transaction is valid");
|
||||||
|
@ -155,8 +155,8 @@ public class HSQLDBArbitraryRepository implements ArbitraryRepository {
|
|||||||
ArbitraryDataFile arbitraryDataFile = ArbitraryDataFile.fromHash(hash, signature);
|
ArbitraryDataFile arbitraryDataFile = ArbitraryDataFile.fromHash(hash, signature);
|
||||||
arbitraryDataFile.setMetadataHash(metadataHash);
|
arbitraryDataFile.setMetadataHash(metadataHash);
|
||||||
|
|
||||||
// Delete file and chunks
|
// Delete file, chunks, and metadata
|
||||||
arbitraryDataFile.deleteAll();
|
arbitraryDataFile.deleteAll(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -249,7 +249,7 @@ public class ArbitraryTransactionUtils {
|
|||||||
|
|
||||||
ArbitraryDataFile arbitraryDataFile = ArbitraryDataFile.fromHash(completeHash, signature);
|
ArbitraryDataFile arbitraryDataFile = ArbitraryDataFile.fromHash(completeHash, signature);
|
||||||
arbitraryDataFile.setMetadataHash(metadataHash);
|
arbitraryDataFile.setMetadataHash(metadataHash);
|
||||||
arbitraryDataFile.deleteAll();
|
arbitraryDataFile.deleteAll(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void convertFileToChunks(ArbitraryTransactionData arbitraryTransactionData, long now, long cleanupAfter) throws DataException {
|
public static void convertFileToChunks(ArbitraryTransactionData arbitraryTransactionData, long now, long cleanupAfter) throws DataException {
|
||||||
|
Loading…
Reference in New Issue
Block a user