Skip to content

Commit

Permalink
Make OsmCache.getKey a static method (#857)
Browse files Browse the repository at this point in the history
BundleController now no longer depends on `OSMCache` as a component.
  • Loading branch information
trevorgerhardt authored Feb 2, 2023
1 parent 1037eca commit f36dec3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,11 @@ public class BundleController implements HttpController {

private final FileStorage fileStorage;
private final GTFSCache gtfsCache;
// FIXME The backend appears to use an osmcache purely to get a file key at which to store incoming OSM. Refactor.
private final OSMCache osmCache;
private final TaskScheduler taskScheduler;

public BundleController (BackendComponents components) {
this.fileStorage = components.fileStorage;
this.gtfsCache = components.gtfsCache;
this.osmCache = components.osmCache;
this.taskScheduler = components.taskScheduler;
}

Expand Down Expand Up @@ -176,7 +173,7 @@ private Bundle create (Request req, Response res) {
osm.close();
checkWgsEnvelopeSize(osmBounds, "OSM data");
// Store the source OSM file. Note that we're not storing the derived MapDB file here.
fileStorage.moveIntoStorage(osmCache.getKey(bundle.osmId), fi.getStoreLocation());
fileStorage.moveIntoStorage(OSMCache.getKey(bundle.osmId), fi.getStoreLocation());
}

if (bundle.feedGroupId == null) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/conveyal/r5/streets/OSMCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ public OSMCache (FileStorage fileStorage) {
.maximumSize(10)
.build();

public String cleanId(String id) {
public static String cleanId(String id) {
return id.replaceAll("[^A-Za-z0-9]", "-");
}

public FileStorageKey getKey (String id) {
public static FileStorageKey getKey (String id) {
// FIXME Transforming IDs each time they're used seems problematic. They should probably only be validated here.
String cleanId = cleanId(id);
return new FileStorageKey(FileCategory.BUNDLES, cleanId + ".pbf");
Expand Down

0 comments on commit f36dec3

Please sign in to comment.