コード例 #1
0
    def DoDeferredPhysicalDeletes(self):

        num_files_deleted = 0
        num_thumbnails_deleted = 0

        pauser = HydrusData.BigJobPauser()

        (file_hash, thumbnail_hash) = self.Read('deferred_physical_delete')

        while (file_hash is not None
               or thumbnail_hash is not None) and not HG.view_shutdown:

            if file_hash is not None:

                path = ServerFiles.GetExpectedFilePath(file_hash)

                if os.path.exists(path):

                    HydrusPaths.RecyclePath(path)

                    num_files_deleted += 1

            if thumbnail_hash is not None:

                path = ServerFiles.GetExpectedThumbnailPath(thumbnail_hash)

                if os.path.exists(path):

                    HydrusPaths.RecyclePath(path)

                    num_thumbnails_deleted += 1

            self.WriteSynchronous('clear_deferred_physical_delete',
                                  file_hash=file_hash,
                                  thumbnail_hash=thumbnail_hash)

            (file_hash, thumbnail_hash) = self.Read('deferred_physical_delete')

            pauser.Pause()

        if num_files_deleted > 0 or num_thumbnails_deleted > 0:

            HydrusData.Print(
                'Physically deleted {} files and {} thumbnails from file storage.'
                .format(HydrusData.ToHumanInt(num_files_deleted),
                        HydrusData.ToHumanInt(num_files_deleted)))
コード例 #2
0
def DeletePath(path, always_delete_fully=False):

    if HC.options['delete_to_recycle_bin'] == True and not always_delete_fully:

        HydrusPaths.RecyclePath(path)

    else:

        HydrusPaths.DeletePath(path)