Example #1
0
    def delete_marked(self):
        if not confirm(
                '<p>' + _('The marked files and folders will be '
                          '<b>permanently deleted</b>. Are you sure?') +
                '</p>', 'check_library_editor_delete', self):
            return

        # Sort the paths in reverse length order so that we can be sure that
        # if an item is in another item, the sub-item will be deleted first.
        items = sorted(self.all_items,
                       key=lambda x: len(x.text(1)),
                       reverse=True)
        for it in items:
            if it.checkState(1):
                try:
                    p = os.path.join(self.db.library_path, unicode(it.text(1)))
                    if os.path.isdir(p):
                        delete_tree(p)
                    else:
                        delete_file(p)
                except:
                    prints(
                        'failed to delete',
                        os.path.join(self.db.library_path,
                                     unicode(it.text(1))))
        self.run_the_check()
Example #2
0
def delete_book(db, book_id, book_path, dbdir):
  delete_book_from_db(db, book_id)
  book_dir = os.path.join(dbdir, book_path.replace('/', os.sep))
  if os.path.exists(book_dir):
    recycle_bin.delete_tree(book_dir, permanent=True)
    try:
      os.rmdir(os.path.dirname(book_dir))  # Remove empty author dir.
    except OSError:
      pass
Example #3
0
 def do_delete(self, x):
     if os.path.isdir(x):
         delete_tree(x)
     else:
         delete_file(x)
     try:
         os.rmdir(os.path.dirname(x))
     except OSError as e:
         if e.errno != errno.ENOTEMPTY:
             raise
Example #4
0
 def do_delete(self, x):
     if os.path.isdir(x):
         delete_tree(x)
     else:
         delete_file(x)
     try:
         os.rmdir(os.path.dirname(x))
     except OSError as e:
         if e.errno != errno.ENOTEMPTY:
             raise
Example #5
0
 def do_delete(self, tdir):
     if os.path.exists(tdir):
         try:
             for x in os.listdir(tdir):
                 x = os.path.join(tdir, x)
                 if os.path.isdir(x):
                     delete_tree(x)
                 else:
                     delete_file(x)
         finally:
             shutil.rmtree(tdir)
Example #6
0
 def do_delete(self, tdir):
     if os.path.exists(tdir):
         try:
             for x in os.listdir(tdir):
                 x = os.path.join(tdir, x)
                 if os.path.isdir(x):
                     delete_tree(x)
                 else:
                     delete_file(x)
         finally:
             shutil.rmtree(tdir)
Example #7
0
    def delete_marked(self):
        if not confirm('<p>'+_('The marked files and folders will be '
               '<b>permanently deleted</b>. Are you sure?') + '</p>', 'check_library_editor_delete', self):
            return

        # Sort the paths in reverse length order so that we can be sure that
        # if an item is in another item, the sub-item will be deleted first.
        items = sorted(self.all_items,
                       key=lambda x: len(x.text(1)),
                       reverse=True)
        for it in items:
            if it.checkState(1):
                try:
                    p = os.path.join(self.db.library_path ,unicode(it.text(1)))
                    if os.path.isdir(p):
                        delete_tree(p)
                    else:
                        delete_file(p)
                except:
                    prints('failed to delete',
                            os.path.join(self.db.library_path,
                                unicode(it.text(1))))
        self.run_the_check()
Example #8
0
 def rmtree(self, path, permanent=False):
     if not self.normpath(self.library_path).startswith(
             self.normpath(path)):
         delete_tree(path, permanent=permanent)
Example #9
0
 def rmtree(self, path, permanent=False):
     if not self.normpath(self.library_path).startswith(self.normpath(path)):
         delete_tree(path, permanent=permanent)