func Destroy(scene *models.Scene, repo models.Repository, fileDeleter *FileDeleter, deleteGenerated, deleteFile bool) error {
	qb := repo.Scene()
	mqb := repo.SceneMarker()

	markers, err := mqb.FindBySceneID(scene.ID)
	if err != nil {
		return err
	}

	for _, m := range markers {
		if err := DestroyMarker(scene, m, mqb, fileDeleter); err != nil {
			return err
		}
	}

	if deleteFile {
		if err := fileDeleter.Files([]string{scene.Path}); err != nil {
			return err
		}

		funscriptPath := GetFunscriptPath(scene.Path)
		funscriptExists, _ := fsutil.FileExists(funscriptPath)
		if funscriptExists {
			if err := fileDeleter.Files([]string{funscriptPath}); err != nil {
				return err
			}
		}
	}

	if deleteGenerated {
		if err := fileDeleter.MarkGeneratedFiles(scene); err != nil {
			return err
		}
	}

	if err := qb.Destroy(scene.ID); err != nil {
		return err
	}

	return nil
}
// Destroy deletes a scene and its associated relationships from the
// database.
Destroy deletes a scene and its associated relationships from the
database.
// Destroy deletes a scene and its associated relationships from the // database .
func Destroy(scene *models.Scene, repo models.Repository, fileDeleter *FileDeleter, deleteGenerated, deleteFile bool) error {
	qb := repo.Scene()
	mqb := repo.SceneMarker()
	markers, err := mqb.FindBySceneID(scene.ID)
	if err != nil {
		return err
	}
	for _, m := range markers {
		if err := DestroyMarker(scene, m, mqb, fileDeleter); err != nil {
			return err
		}
	}
	if deleteFile {
		if err := fileDeleter.Files([]string{scene.Path}); err != nil {
			return err
		}
		funscriptPath := GetFunscriptPath(scene.Path)
		funscriptExists, _ := fsutil.FileExists(funscriptPath)
		if funscriptExists {
			if err := fileDeleter.Files([]string{funscriptPath}); err != nil {
				return err
			}
		}
	}
	if deleteGenerated {
		if err := fileDeleter.MarkGeneratedFiles(scene); err != nil {
			return err
		}
	}
	if err := qb.Destroy(scene.ID); err != nil {
		return err
	}
	return nil
}
func Destroy ( scene * models . Scene , repo models . Repository , fileDeleter * FileDeleter , deleteGenerated , deleteFile bool ) error { qb := repo . Scene ( ) mqb := repo . SceneMarker ( ) markers , err := mqb . FindBySceneID ( scene . ID ) if err != nil { return err } for _ , m := range markers { if err := DestroyMarker ( scene , m , mqb , fileDeleter ) ; err != nil { return err } } if deleteFile { if err := fileDeleter . Files ( [ ] string { scene . Path } ) ; err != nil { return err } funscriptPath := GetFunscriptPath ( scene . Path ) funscriptExists , _ := fsutil . FileExists ( funscriptPath ) if funscriptExists { if err := fileDeleter . Files ( [ ] string { funscriptPath } ) ; err != nil { return err } } } if deleteGenerated { if err := fileDeleter . MarkGeneratedFiles ( scene ) ; err != nil { return err } } if err := qb . Destroy ( scene . ID ) ; err != nil { return err } return nil }
Destroy deletes a scene and its associated relationships from the
database.
Destroy deletes a scene and its associated relationships from the database .