You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by re...@apache.org on 2021/12/15 15:32:04 UTC

[jackrabbit-filevault] branch JCRVLT-575 created (now 9cdb6bd)

This is an automated email from the ASF dual-hosted git repository.

reschke pushed a change to branch JCRVLT-575
in repository https://gitbox.apache.org/repos/asf/jackrabbit-filevault.git.


      at 9cdb6bd  JCRVLT-575: handle symlinks in homeDir path

This branch includes the following new commits:

     new 9cdb6bd  JCRVLT-575: handle symlinks in homeDir path

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


[jackrabbit-filevault] 01/01: JCRVLT-575: handle symlinks in homeDir path

Posted by re...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

reschke pushed a commit to branch JCRVLT-575
in repository https://gitbox.apache.org/repos/asf/jackrabbit-filevault.git

commit 9cdb6bdf2c287793166d18191e2345d0a8d5a6f6
Author: Julian Reschke <ju...@gmx.de>
AuthorDate: Wed Dec 15 16:31:47 2021 +0100

    JCRVLT-575: handle symlinks in homeDir path
---
 .../packaging/registry/impl/FSInstallStateCache.java    | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/registry/impl/FSInstallStateCache.java b/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/registry/impl/FSInstallStateCache.java
index a68de14..35c749f 100644
--- a/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/registry/impl/FSInstallStateCache.java
+++ b/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/registry/impl/FSInstallStateCache.java
@@ -18,6 +18,7 @@ package org.apache.jackrabbit.vault.packaging.registry.impl;
 
 import java.io.IOException;
 import java.io.UncheckedIOException;
+import java.nio.file.FileVisitOption;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.util.AbstractMap;
@@ -30,6 +31,8 @@ import java.util.stream.Stream;
 
 import org.apache.jackrabbit.vault.packaging.PackageId;
 import org.jetbrains.annotations.NotNull;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * Persisted cache of all {@link FSInstallState} objects for all packages in a registry.
@@ -39,6 +42,8 @@ import org.jetbrains.annotations.NotNull;
  */
 class FSInstallStateCache extends AbstractMap<PackageId, FSInstallState> {
 
+    private static final Logger log = LoggerFactory.getLogger(FSInstallStateCache.class);
+
     /**
      * Extension for metadata files
      */
@@ -53,10 +58,14 @@ class FSInstallStateCache extends AbstractMap<PackageId, FSInstallState> {
     private Map<Path, PackageId> pathIdMapping = new ConcurrentHashMap<>();
 
     private final Path homeDir;
-    
+
     public FSInstallStateCache(Path homeDir) throws IOException {
         this.homeDir = homeDir;
-        Files.createDirectories(homeDir);
+        log.debug("checking for presence of {} - exists {} - isDirectory {}", homeDir, Files.exists(homeDir), Files.isDirectory(homeDir));
+        if (Files.notExists(homeDir)) {
+            Path created = Files.createDirectories(homeDir);
+            log.debug("Created {}", created);
+        }
     }
 
     /**
@@ -68,12 +77,14 @@ class FSInstallStateCache extends AbstractMap<PackageId, FSInstallState> {
         Map<Path, PackageId> idMapping = new HashMap<>();
 
         // recursively find meta file
-        try (Stream<Path> stream = Files.walk(homeDir, 10)) {
+        log.debug("loading state from home directory {}", homeDir);
+        try (Stream<Path> stream = Files.walk(homeDir, 10, FileVisitOption.FOLLOW_LINKS)) {
             stream.filter(Files::isRegularFile).filter(p -> p.toString().endsWith(META_EXTENSION)).forEach(
                 p -> {
                     FSInstallState state;
                     try {
                         state = FSInstallState.fromFile(p);
+                        log.debug("loaded state from {}", p);
                     } catch (IOException e) {
                         throw new UncheckedIOException(e);
                     }