diff options
author | Harald Musum <musum@yahooinc.com> | 2022-11-23 14:20:38 +0100 |
---|---|---|
committer | Harald Musum <musum@yahooinc.com> | 2022-11-23 14:20:38 +0100 |
commit | 1286810d37f0b230cb2311dcfd548b2c02ad2134 (patch) | |
tree | fd7c57c2c37f75d296ab45fd977d02291f8f85f6 /configserver | |
parent | 02dbfdece2c0bc6a1e2352c737da9c2ba7ae3d82 (diff) |
Use FileDirectory to delete file reference
Diffstat (limited to 'configserver')
-rw-r--r-- | configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionRepository.java | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionRepository.java b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionRepository.java index 0c7fc217e40..79755da9726 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionRepository.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionRepository.java @@ -29,6 +29,7 @@ import com.yahoo.vespa.config.server.application.PermanentApplicationPackage; import com.yahoo.vespa.config.server.application.TenantApplications; import com.yahoo.vespa.config.server.configchange.ConfigChangeActions; import com.yahoo.vespa.config.server.deploy.TenantFileSystemDirs; +import com.yahoo.vespa.config.server.filedistribution.FileDirectory; import com.yahoo.vespa.config.server.filedistribution.FileDistributionFactory; import com.yahoo.vespa.config.server.http.InvalidApplicationException; import com.yahoo.vespa.config.server.http.UnknownVespaVersionException; @@ -860,9 +861,9 @@ public class SessionRepository { } /** - * Create a new local session for the given session id if it does not already exist. - * Will also add the session to the local session cache if necessary. If there is no - * remote session matching the session it will also be created. + * Create a new local session for the given session id if it does not already exist and + * will add the session to the local session cache. If there is no remote session matching + * the session id the remote session will also be created. */ public void createLocalSessionFromDistributedApplicationPackage(long sessionId) { if (applicationRepo.sessionExistsInFileSystem(sessionId)) { @@ -876,8 +877,9 @@ public class SessionRepository { log.log(Level.FINE, () -> "File reference for session id " + sessionId + ": " + fileReference); if (fileReference != null) { File sessionDir; + FileDirectory fileDirectory = fileDistributionFactory.fileDirectory(); try { - sessionDir = fileDistributionFactory.fileDirectory().getFile(fileReference); + sessionDir = fileDirectory.getFile(fileReference); } catch (IllegalArgumentException e) { // We cannot be guaranteed that the file reference exists (it could be that it has not // been downloaded yet), and e.g. when bootstrapping we cannot throw an exception in that case @@ -890,9 +892,8 @@ public class SessionRepository { try { createLocalSession(sessionDir, applicationId, sessionZKClient.readTags(), sessionId); } finally { - // Delete downloaded file reference, not needed anymore - log.log(Level.FINE, "Deleting file distribution reference for app package with session id " + sessionDir); - IOUtils.recursiveDeleteDir(sessionDir); + log.log(Level.FINE, "Deleting file distribution reference " + fileReference + " for app package with session id " + sessionId); + fileDirectory.delete(fileReference, (reference) -> true); // Delete downloaded file reference, not needed anymore } } } |