(executor) Export Data actor allocates its own storage

This commit is contained in:
Viktor Lofgren 2023-10-31 17:04:07 +01:00
parent cbac42bdd1
commit 659743b39c
2 changed files with 5 additions and 2 deletions

View File

@ -11,7 +11,7 @@ public enum FileStorageBaseType {
public boolean permitsStorageType(FileStorageType type) {
return switch (this) {
case BACKUP -> FileStorageType.BACKUP.equals(type);
case STORAGE -> EnumSet.of(FileStorageType.CRAWL_DATA, FileStorageType.PROCESSED_DATA, FileStorageType.CRAWL_SPEC).contains(type);
case STORAGE -> EnumSet.of(FileStorageType.EXPORT, FileStorageType.CRAWL_DATA, FileStorageType.PROCESSED_DATA, FileStorageType.CRAWL_SPEC).contains(type);
default -> false;
};
}

View File

@ -10,6 +10,7 @@ import lombok.With;
import nu.marginalia.actor.prototype.RecordActorPrototype;
import nu.marginalia.actor.state.ActorStep;
import nu.marginalia.storage.FileStorageService;
import nu.marginalia.storage.model.FileStorageBaseType;
import nu.marginalia.storage.model.FileStorageId;
import nu.marginalia.storage.model.FileStorageType;
import org.slf4j.Logger;
@ -21,6 +22,7 @@ import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import java.nio.file.StandardOpenOption;
import java.nio.file.attribute.PosixFilePermissions;
import java.time.LocalDateTime;
import java.util.zip.GZIPOutputStream;
@Singleton
@ -47,7 +49,8 @@ public class ExportDataActor extends RecordActorPrototype {
public ActorStep transition(ActorStep self) throws Exception {
return switch(self) {
case Export() -> {
var storage = storageService.getStorageByType(FileStorageType.EXPORT);
var storageBase = storageService.getStorageBase(FileStorageBaseType.STORAGE);
var storage = storageService.allocateTemporaryStorage(storageBase, FileStorageType.EXPORT, "db-export", "DB Exports " + LocalDateTime.now());
if (storage == null) yield new Error("Bad storage id");
yield new ExportBlacklist(storage.id());