REMOVE deleteFile in DirectoryService and replace with local methods
This commit is contained in:
@@ -6,6 +6,7 @@ import com.ddf.vodsystem.entities.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
@@ -175,7 +176,6 @@ public class ClipService {
|
||||
throw new FFMPEGException("Error retrieving video metadata for clip: " + e.getMessage());
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
thumbnailService.createThumbnail(clipFile, thumbnailFile, 0.0f);
|
||||
} catch (IOException | InterruptedException e) {
|
||||
@@ -205,15 +205,11 @@ public class ClipService {
|
||||
File clipFile = new File(clip.getVideoPath());
|
||||
File thumbnailFile = new File(clip.getThumbnailPath());
|
||||
|
||||
boolean clipDeleted = directoryService.deleteFile(clipFile);
|
||||
boolean thumbnailDeleted = directoryService.deleteFile(thumbnailFile);
|
||||
|
||||
if (!clipDeleted) {
|
||||
throw new FFMPEGException("Failed to delete clip file: " + clipFile.getAbsolutePath());
|
||||
}
|
||||
|
||||
if (!thumbnailDeleted) {
|
||||
throw new FFMPEGException("Failed to delete thumbnail file: " + thumbnailFile.getAbsolutePath());
|
||||
try {
|
||||
Files.deleteIfExists(clipFile.toPath());
|
||||
Files.deleteIfExists(thumbnailFile.toPath());
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,22 +110,6 @@ public class DirectoryService {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean deleteFile(File file) {
|
||||
if (file == null || !file.exists()) {
|
||||
logger.warn("File does not exist: {}", file);
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
Files.delete(file.toPath());
|
||||
logger.debug("Deleted file: {}", file.getAbsolutePath());
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
logger.error("Error deleting file: {}", e.getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public String getFileExtension(String filePath) {
|
||||
Path path = Paths.get(filePath);
|
||||
String fileName = path.getFileName().toString();
|
||||
|
||||
@@ -2,6 +2,8 @@ package com.ddf.vodsystem.services;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import com.ddf.vodsystem.dto.Job;
|
||||
@@ -75,13 +77,17 @@ public class JobService {
|
||||
job.getInputClipOptions().getDuration())
|
||||
.thenRun(() -> {
|
||||
job.getStatus().getConversion().markComplete();
|
||||
directoryService.deleteFile(tempFile);
|
||||
|
||||
try {
|
||||
Files.deleteIfExists(Paths.get(tempFile.getAbsolutePath()));
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
});
|
||||
} catch (IOException | InterruptedException e) {
|
||||
logger.error("Error converting job {}: {}", job.getUuid(), e.getMessage());
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user