MavenConfig не нужен
This commit is contained in:
@@ -1,19 +0,0 @@
|
||||
package ru.di9.mirror.config;
|
||||
|
||||
import lombok.Getter;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
@Configuration
|
||||
@Getter
|
||||
public class MavenConfig {
|
||||
|
||||
private final Path storagePath;
|
||||
|
||||
public MavenConfig(@Value("${maven.storage:./storage}") String storagePath) {
|
||||
this.storagePath = Paths.get(storagePath);
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
package ru.di9.mirror.services;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.di9.mirror.Utils;
|
||||
import ru.di9.mirror.config.MavenConfig;
|
||||
import ru.di9.mirror.domain.FileRecord;
|
||||
import ru.di9.mirror.domain.PathRecord;
|
||||
import ru.di9.mirror.domain.PathType;
|
||||
@@ -13,6 +13,7 @@ import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
@@ -21,10 +22,10 @@ import java.util.stream.Stream;
|
||||
@Service
|
||||
public class FileStorageService implements StorageService {
|
||||
|
||||
private final MavenConfig config;
|
||||
private final Path storagePath;
|
||||
|
||||
public FileStorageService(MavenConfig config) {
|
||||
this.config = config;
|
||||
public FileStorageService(@Value("${maven.storage}") String storagePath) {
|
||||
this.storagePath = Paths.get(storagePath).resolve("local");
|
||||
}
|
||||
|
||||
@SuppressWarnings("java:S112")
|
||||
@@ -106,9 +107,9 @@ public class FileStorageService implements StorageService {
|
||||
|
||||
private Path storageResolve(String httpPath) {
|
||||
if (Utils.isEmptyString(httpPath)) {
|
||||
return config.getStoragePath();
|
||||
return storagePath;
|
||||
} else {
|
||||
return config.getStoragePath().resolve(httpPath.substring(1));
|
||||
return storagePath.resolve(httpPath.substring(1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user