def cleanup(self): """ Remove all dirs and files (including root dir) and all MDBTree nodes for user After that create new root and do full sync() Can be used to restore correct dirs/files structure Returns: celery task_id for frontend """ # Remove all server directories for user try: remove_server_dir(self, '/') except Exception, e: l.error("cleanup_and_sync(): can't remove root dir for user '%s' (%s)" %\ (self.username, e))
def remove_node_as_dir(node_id, skip_dropbox=False, use_ust=True, callback=None): """ Remove node (must be a directory !) Arguments: node_id: node to remove skip_dropbox: if True, only remove from local storage (used in sync) use_ust: if True, process remove in User Synchronous mode """ node, db_sess = _get_node(node_id) if use_ust: if django_settings.ASYNC_DROPBOX: yield gen.Task(async_ust_start, node.user) else: ust_start(node.user) try: # Remove dir from dropbox if asked if not skip_dropbox: # Removes dir from dropbox (recursively) if django_settings.ASYNC_DROPBOX: yield_key = object() db_sess.delete_file(encode_if_unicode(node.db_path), callback=(yield gen.Callback(yield_key))) yield gen.Wait(yield_key) else: db_sess.db_client.file_delete(encode_if_unicode(node.db_path)) else: l.info("remove_node_as_dir: '%s' skipping dropbox removal" %\ (node.db_path, )) # Then from local storage remove_server_dir(node.user, node.db_path) # Go through treebeard to find and delete node's descendants for child in node.get_children(): child.delete() # And finally delete treebeard node node.delete() except Exception, e: err_msg = "remove_node_as_dir: '%s' (%s)" %\ (node.db_path, e,) l.error(err_msg) raise MDBException("ERROR: "+err_msg)