(filename, target)
| 267 | @api.route("/files/<string:target>/<path:filename>", methods=["DELETE"]) |
| 268 | @restricted_access |
| 269 | def deletePrintFile(filename, target): |
| 270 | if not target in [FileDestinations.LOCAL, FileDestinations.SDCARD]: |
| 271 | return make_response("Unknown target: %s" % target, 404) |
| 272 | |
| 273 | if not _verifyFileExists(target, filename): |
| 274 | return make_response("File not found on '%s': %s" % (target, filename), 404) |
| 275 | |
| 276 | sd = target == FileDestinations.SDCARD |
| 277 | |
| 278 | printer = printerManager() |
| 279 | |
| 280 | currentJob = printer.getCurrentJob() |
| 281 | currentFilename = None |
| 282 | currentSd = None |
| 283 | if currentJob is not None and "filename" in currentJob.keys() and "sd" in currentJob.keys(): |
| 284 | currentFilename = currentJob["filename"] |
| 285 | currentSd = currentJob["sd"] |
| 286 | |
| 287 | # prohibit deleting the file that is currently being printed |
| 288 | if currentFilename == filename and currentSd == sd and (printer.isPrinting() or printer.isPaused()): |
| 289 | make_response("Trying to delete file that is currently being printed: %s" % filename, 409) |
| 290 | |
| 291 | # deselect the file if it's currently selected |
| 292 | if currentFilename is not None and filename == currentFilename: |
| 293 | printer.unselectFile() |
| 294 | |
| 295 | # delete it |
| 296 | if sd: |
| 297 | printer.deleteSdFile(filename) |
| 298 | else: |
| 299 | printer.fileManager.removeFile(filename) |
| 300 | |
| 301 | return NO_CONTENT |
| 302 | |
| 303 | #external drive managing |
| 304 | @api.route("/files/folder-contents", methods=["GET"]) |
nothing calls this directly
no test coverage detected