(self, data, sendResponse)
| 217 | sendResponse('invalid_filename', True) |
| 218 | |
| 219 | def deletePrintFile(self, data, sendResponse): |
| 220 | |
| 221 | fileDestination = fileName = None |
| 222 | |
| 223 | if 'location' in data: |
| 224 | fileDestination = data['location'] |
| 225 | |
| 226 | if 'fileName' in data: |
| 227 | fileName = data['fileName'] |
| 228 | |
| 229 | if not fileDestination in [FileDestinations.LOCAL, FileDestinations.SDCARD]: |
| 230 | self._logger.error("Unknown file location") |
| 231 | sendResponse('unknown_file_location',True) |
| 232 | return |
| 233 | |
| 234 | if not fileName or not self._verifyFileExists(fileDestination, fileName): |
| 235 | self._logger.error("File not found") |
| 236 | sendResponse('file_not_found',True) |
| 237 | return |
| 238 | |
| 239 | sd = fileDestination == FileDestinations.SDCARD |
| 240 | |
| 241 | printer = printerManager() |
| 242 | |
| 243 | currentJob = printer.getCurrentJob() |
| 244 | currentFilename = None |
| 245 | currentSd = None |
| 246 | if currentJob is not None and "fileName" in currentJob.keys() and "sd" in currentJob.keys(): |
| 247 | currentFilename = currentJob["fileName"] |
| 248 | currentSd = currentJob["sd"] |
| 249 | |
| 250 | # prohibit deleting the file that is currently being printed |
| 251 | if currentFilename == fileName and currentSd == sd and (printer.isPrinting() or printer.isPaused()): |
| 252 | sendResponse("Trying to delete file that is currently being printed: %s" % fileName,true) |
| 253 | |
| 254 | # deselect the file if it's currently selected |
| 255 | if currentFilename is not None and fileName == currentFilename: |
| 256 | printer.unselectFile() |
| 257 | |
| 258 | # delete it |
| 259 | if sd: |
| 260 | printer.deleteSdFile(fileName) |
| 261 | else: |
| 262 | printer.fileManager.removeFile(fileName) |
| 263 | |
| 264 | eventManager().fire(Events.FILE_DELETED, {"filename": fileName}) |
| 265 | |
| 266 | self.publishEvent('file_deleted','deleted') |
| 267 | |
| 268 | sendResponse({'success':'no error'}) |
| 269 | |
| 270 | |
| 271 | def downloadPrintFile(self,printFileId,sendResponse): |
nothing calls this directly
no test coverage detected