in app/services/NewProjectBackup.scala [518:558]
def deleteAudioBackupsFor(projectAndFiles:(ProjectEntry, Seq[FileEntry]), storageDrivers:Map[Int, StorageDriver]):Future[Seq[Unit]] = {
val p = projectAndFiles._1
val backupFiles = projectAndFiles._2.filter(_.backupOf.isDefined)
val audioBackups = backupFiles.filter(fileEntry=>{
if(fileEntry.filepath.endsWith(".cpr")) {
logger.debug(s"Found Cubase file: ${fileEntry.filepath}")
true
} else if(fileEntry.filepath.endsWith(".sesx")) {
logger.debug(s"Found Audition file: ${fileEntry.filepath}")
true
} else {
false
}
})
logger.info(s"Project ${p.projectTitle} (${p.id.get}) has ${audioBackups.length} audio backups")
Future.sequence(
audioBackups.map(fileEntry=>{
storageDrivers.get(fileEntry.storageId) match {
case None=>
logger.error(s"Could not get a storage driver for ${fileEntry.filepath} on storage id ${fileEntry.storageId}")
Future.failed(new RuntimeException("Could not get a storage driver on the second pass, this should not happen!"))
case Some(driver)=>
if(fileEntry.storageId!=2) {
logger.info(s"Deleting backup ${fileEntry.filepath} on storage id ${fileEntry.storageId}")
if (driver.deleteFileAtPath(fileEntry.filepath, fileEntry.version)) {
logger.info(s"Deleting backup entry ${fileEntry.id}")
fileEntry.deleteSelf
} else {
logger.error(s"Could not delete file ${fileEntry.filepath} on storage id ${fileEntry.storageId}")
Future( () )
}
} else {
Future( () )
}
}
})
)
}