Arbitrary transaction names are now case insensitive

This commit is contained in:
CalDescent 2021-10-15 13:58:27 +01:00
parent c8d5ac9248
commit f0e13fa492
4 changed files with 19 additions and 5 deletions

View File

@ -24,7 +24,7 @@ public class ArbitraryDataBuildQueueItem {
public static long FAILURE_TIMEOUT = 5*60*1000L; // 5 minutes
public ArbitraryDataBuildQueueItem(String resourceId, ResourceIdType resourceIdType, Service service) {
this.resourceId = resourceId;
this.resourceId = resourceId.toLowerCase();
this.resourceIdType = resourceIdType;
this.service = service;
this.creationTimestamp = NTP.getTime();

View File

@ -84,6 +84,9 @@ public class ArbitraryDataBuildManager implements Runnable {
}
private void removeFromQueue(String resourceId) {
ArbitraryDataManager.getInstance().arbitraryDataBuildQueue.remove(resourceId);
if (resourceId == null) {
return;
}
ArbitraryDataManager.getInstance().arbitraryDataBuildQueue.remove(resourceId.toLowerCase());
}
}

View File

@ -272,6 +272,10 @@ public class ArbitraryDataManager extends Thread {
// Arbitrary data resource cache
public boolean isResourceCached(String resourceId) {
if (resourceId == null) {
return false;
}
resourceId = resourceId.toLowerCase();
// We don't have an entry for this resource ID, it is not cached
if (this.arbitraryDataCachedResources == null) {
@ -297,6 +301,11 @@ public class ArbitraryDataManager extends Thread {
}
public void addResourceToCache(String resourceId) {
if (resourceId == null) {
return;
}
resourceId = resourceId.toLowerCase();
// Just in case
if (this.arbitraryDataCachedResources == null) {
this.arbitraryDataCachedResources = new HashMap<>();
@ -319,6 +328,7 @@ public class ArbitraryDataManager extends Thread {
if (resourceId == null) {
return false;
}
resourceId = resourceId.toLowerCase();
if (this.arbitraryDataBuildQueue == null) {
return false;
@ -398,6 +408,7 @@ public class ArbitraryDataManager extends Thread {
if (resourceId == null) {
return false;
}
resourceId = resourceId.toLowerCase();
if (this.arbitraryDataFailedBuilds == null) {
return false;
@ -537,7 +548,7 @@ public class ArbitraryDataManager extends Thread {
// so that it is rebuilt the next time we serve it
if (arbitraryDataFile.exists() || arbitraryDataFile.allChunksExist(arbitraryTransactionData.getChunkHashes())) {
if (arbitraryTransactionData.getName() != null) {
String resourceId = arbitraryTransactionData.getName();
String resourceId = arbitraryTransactionData.getName().toLowerCase();
if (this.arbitraryDataCachedResources.containsKey(resourceId)) {
this.arbitraryDataCachedResources.remove(resourceId);
}

View File

@ -229,7 +229,7 @@ public class HSQLDBArbitraryRepository implements ArbitraryRepository {
"version, nonce, service, size, is_data_raw, data, chunk_hashes, " +
"name, update_method, secret, compression FROM ArbitraryTransactions " +
"JOIN Transactions USING (signature) " +
"WHERE name = ? AND service = ?");
"WHERE lower(name) = ? AND service = ?");
if (method != null) {
sql.append(" AND update_method = ");
@ -238,7 +238,7 @@ public class HSQLDBArbitraryRepository implements ArbitraryRepository {
sql.append("ORDER BY created_when DESC LIMIT 1");
try (ResultSet resultSet = this.repository.checkedExecute(sql.toString(), name, service.value)) {
try (ResultSet resultSet = this.repository.checkedExecute(sql.toString(), name.toLowerCase(), service.value)) {
if (resultSet == null)
return null;