Skip to content

Commit

Permalink
Merge pull request #123 from reportportal/EPMRPP-88755-add-prefix-and…
Browse files Browse the repository at this point in the history
…-postfix-for-filesystem

EPMRPP-88755 || Add prefix and postfix for filesystem
  • Loading branch information
pbortnik authored Dec 14, 2023
2 parents db77b0f + 80e898a commit 23d778f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,13 @@ public BlobStore filesystemBlobStore(
@ConditionalOnProperty(name = "datastore.type", havingValue = "filesystem")
public DataStorageService localDataStore(@Autowired BlobStore blobStore,
FeatureFlagHandler featureFlagHandler,
@Value("${datastore.path:/data/store}") String baseDirectory) {
return new LocalDataStorageService(blobStore, featureFlagHandler, baseDirectory);
@Value("${datastore.path:/data/store}") String baseDirectory,
@Value("${datastore.bucketPrefix}") String bucketPrefix,
@Value("${datastore.bucketPostfix}") String bucketPostfix,
@Value("${datastore.defaultBucketName}") String defaultBucketName) {
return new LocalDataStorageService(blobStore, featureFlagHandler, baseDirectory, bucketPrefix,
bucketPostfix, defaultBucketName
);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,24 @@ public class LocalDataStorageService implements DataStorageService {

private final String baseDirectory;

private final String bucketPrefix;

private final String bucketPostfix;

private final String defaultBucketName;

private static final String PROJECT_PREFIX = "project-data";

private static final String SINGLE_BUCKET_NAME = "store";

public LocalDataStorageService(BlobStore blobStore, FeatureFlagHandler featureFlagHandler,
String baseDirectory) {
String baseDirectory, String bucketPrefix, String bucketPostfix, String defaultBucketName) {
this.blobStore = blobStore;
this.featureFlagHandler = featureFlagHandler;
this.baseDirectory = baseDirectory;
this.bucketPrefix = bucketPrefix;
this.bucketPostfix = bucketPostfix;
this.defaultBucketName = defaultBucketName;
}

@Override
Expand All @@ -65,15 +74,15 @@ public void deleteAll(List<String> paths) throws Exception {
Map<String, List<String>> bucketPathMap = retrieveBucketPathMap(paths);
for (Map.Entry<String, List<String>> bucketPaths : bucketPathMap.entrySet()) {
removeFiles(
SINGLE_BUCKET_NAME,
defaultBucketName,
bucketPaths.getValue().stream().map(s -> bucketPaths.getKey() + "/" + s).toList()
);
deleteEmptyDirs(Paths.get(baseDirectory, SINGLE_BUCKET_NAME, PROJECT_PREFIX));
}
} else {
Map<String, List<String>> bucketPathMap = retrieveBucketPathMap(paths);
for (Map.Entry<String, List<String>> bucketPaths : bucketPathMap.entrySet()) {
removeFiles(bucketPaths.getKey(), bucketPaths.getValue());
removeFiles(bucketPrefix + bucketPaths.getKey() + bucketPostfix, bucketPaths.getValue());
deleteEmptyDirs(Paths.get(baseDirectory, bucketPaths.getKey()));
}
}
Expand Down

0 comments on commit 23d778f

Please sign in to comment.