Ejemplo n.º 1
0
def remove_metadata(user_name, path):
    user_key = userinfo.get_user_key(user_name)
    if user_key == None:
        raise Exception('user not exist')
    
    q = MetadataModel.all()
    q.filter('user =', user_name)
    q.filter("md5_path =", hashlib.md5(path).hexdigest())
    for item in q.run():
        item.delete()
        userinfo._on_file_removed(_dict_metadata(item))
Ejemplo n.º 2
0
def list_metadata(user_name):
    user_key = userinfo.get_user_key(user_name)
    if user_key == None:
        raise Exception('user not exist')
    
    q = MetadataModel.all()
    q.filter('user =', user_name)
    metadata_list = {}
    for metadata in q.run():
        metadata_list[metadata.path] = _dict_metadata(metadata)
    
    return metadata_list
Ejemplo n.º 3
0
def get_metadata(user_name, path):
    user_key = userinfo.get_user_key(user_name)
    if user_key == None:
        raise Exception('user not exist')
    
    q = MetadataModel.all()
    q.filter('user =', user_name) 
    q.filter("md5_path =", hashlib.md5(path).hexdigest())
    
    r = q.get()
    if r != None:
        return _dict_metadata(r)
    else:
        return None
Ejemplo n.º 4
0
def put_metadata(user_name, path, size, mtime, sha1):
    remove_metadata(user_name, path)
    
    user_key = userinfo.get_user_key(user_name)
    if user_key == None:
        raise Exception('user not exist')
    
    mm = MetadataModel(
        user = user_name,
        path = path,
        md5_path = hashlib.md5(path).hexdigest(),
        size = size,
        mtime = mtime,
        sha1 = sha1)
    mm.put()
    userinfo._on_file_created(_dict_metadata(mm))