cecemei commented on code in PR #18176:
URL: https://github.com/apache/druid/pull/18176#discussion_r2226777826


##########
server/src/main/java/org/apache/druid/segment/loading/SegmentLocalCacheManager.java:
##########
@@ -163,12 +193,45 @@ public List<DataSegment> getCachedSegments() throws 
IOException
       log.info("Loading segment cache file [%d/%d][%s].", i + 1, 
segmentsToLoad.length, file);
       try {
         final DataSegment segment = jsonMapper.readValue(file, 
DataSegment.class);
+        boolean removeInfo = false;
         if (!segment.getId().toString().equals(file.getName())) {
           log.warn("Ignoring cache file[%s] for segment[%s].", file.getPath(), 
segment.getId());
           ignored++;
-        } else if (isSegmentCached(segment)) {
-          cachedSegments.add(segment);
         } else {
+          removeInfo = true;
+          final SegmentCacheEntry cacheEntry = new SegmentCacheEntry(segment);
+          for (StorageLocation location : locations) {
+            // check for migrate from old nested local storage path format
+            final File legacyPath = new File(location.getPath(), 
DataSegmentPusher.getDefaultStorageDir(segment, false));
+            if (legacyPath.exists()) {
+              FileUtils.mkdirp(new File(location.getPath(), 
segment.getId().toString()));
+              Files.move(legacyPath.toPath(), 
cacheEntry.toPotentialLocation(location.getPath()).toPath(), 
StandardCopyOption.REPLACE_EXISTING);
+              cleanupLegacyCacheLocation(location.getPath(), legacyPath);
+            }
+
+            if (cacheEntry.checkExists(location.getPath())) {

Review Comment:
   nit: this `checkExists` is not quite necessary since we already have 
`toPotentialLocation`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to