def _trash_page(self, path): from zim.newfs.helpers import TrashHelper logger.debug('Trash page: %s', path) if self.config['Notebook']['disable_trash']: raise TrashNotSupportedError('disable_trash is set') self.emit('delete-page', path) file, folder = self.layout.map_page(path) helper = TrashHelper() re = False if folder.exists(): re = helper.trash(folder) if isinstance(path, Page): path.haschildren = False if file.exists(): re = helper.trash(file) or re self.index.update_file(file) self.index.update_file(folder) return re
def runTest(self): root = self.setUpFolder(mock=tests.MOCK_ALWAYS_REAL) helper = TrashHelper() file = root.file('test.txt') file.touch() self.assertTrue(file.exists()) self.assertTrue(helper.trash(file)) self.assertFalse(file.exists()) dir = root.folder('test') dir.touch() self.assertTrue(dir.exists()) self.assertTrue(helper.trash(dir)) self.assertFalse(dir.exists()) # fails silent if file does not exist self.assertFalse(helper.trash(file)) self.assertFalse(helper.trash(dir))
def runTest(self): root = LocalFolder(self.create_tmp_dir()) helper = TrashHelper() file = root.file('test.txt') file.touch() self.assertTrue(file.exists()) self.assertTrue(helper.trash(file)) self.assertFalse(file.exists()) dir = root.folder('test') dir.touch() self.assertTrue(dir.exists()) self.assertTrue(helper.trash(dir)) self.assertFalse(dir.exists()) # fails silent if file does not exist self.assertFalse(helper.trash(file)) self.assertFalse(helper.trash(dir))