Close streams/encodes before deleting file

This commit is contained in:
WithoutPants
2019-10-18 07:42:12 +11:00
parent 57073faab7
commit a401a7880e
4 changed files with 135 additions and 9 deletions

View File

@@ -157,6 +157,9 @@ func (r *mutationResolver) SceneDestroy(ctx context.Context, input models.SceneD
// if delete file is true, then delete the file as well
// if it fails, just log a message
if input.DeleteFile != nil && *input.DeleteFile {
// kill any running encoders
manager.KillRunningStreams(scene.Path)
err = os.Remove(scene.Path)
if err != nil {
logger.Warnf("Could not delete file %s: %s", scene.Path, err.Error())
@@ -216,6 +219,9 @@ func deleteGeneratedSceneFiles(scene *models.Scene) {
transcodePath := manager.GetInstance().Paths.Scene.GetTranscodePath(scene.Checksum)
exists, _ = utils.FileExists(transcodePath)
if exists {
// kill any running streams
manager.KillRunningStreams(transcodePath)
err := os.Remove(transcodePath)
if err != nil {
logger.Warnf("Could not delete file %s: %s", transcodePath, err.Error())