Ejemplo n.º 1
0
 def delete(self, file_id):
     try:
         hard_delete = request.args.get('hard_delete', False)
         if not g.file['is_folder']:
             if hard_delete == 'true':
                 os.remove(g.file['uri'])
                 File.delete(file_id)
             else:
                 File.update(file_id, {'status': False})
         else:
             if hard_delete == 'true':
                 folders = Folder.filter(
                     lambda folder: folder['tag'].startswith(g.file['tag']))
                 for folder in folders:
                     files = File.filter({
                         'parent_id': folder['id'],
                         'is_folder': False
                     })
                     File.delete({
                         'parent_id': folder['id'],
                         'is_folder': False
                     })
                     for f in files:
                         os.remove(f['uri'])
             else:
                 File.update(file_id, {'status': False})
                 File.update({'parent_id': file_id}, {'status': False})
         return "File has been deleted successfully", 204
     except:
         abort(500,
               message=
               "There was an error while processing your request --> {0}".
               format(e))
Ejemplo n.º 2
0
 def get(self):
     try:
         return File.filter({'creator': g.user_id})
     except Exception as e:
         abort(500,
               message=
               "There was an error while trying to get your files --> {0}".
               format(e))