Пример #1
0
def FUPT(new_tree, from_who, old_tree, client):
    if from_who == 'server':
        protocol.send_FUPT(new_tree, client)
        if new_tree['kind'] != 0:
            send_chunk_to(client, hash.Hash(new_tree['unique_hash']))

    if from_who == 'client' and old_tree['kind'] != 0:
        # FIXME: it will happen that some clients share identical chunks,
        # do not do this
        make_chunk_disappear(hash.Hash(old_tree['unique_hash']))
        chunk.keep_chunk_alive(client, hash.Hash(new_tree['unique_hash']))

    old_tree['unique_hash'] = new_tree['unique_hash']
Пример #2
0
def FUPT(new_tree, from_who, old_tree, client):
    if from_who == 'server':
        protocol.send_FUPT(new_tree, client)
        if new_tree['kind'] != 0:
            send_chunk_to(client, hash.Hash(new_tree['unique_hash']))

    if from_who == 'client' and old_tree['kind'] != 0:
        # FIXME: it will happen that some clients share identical chunks,
        # do not do this
        make_chunk_disappear(hash.Hash(old_tree['unique_hash']))
        chunk.keep_chunk_alive(client, hash.Hash(new_tree['unique_hash']))

    old_tree['unique_hash'] = new_tree['unique_hash']
Пример #3
0
def FADD(directory, from_who, filename, tree, client):
    logger.debug('user {} adding {} from {}'.format(client.username,
                                                    tree['path'], from_who))

    if from_who == 'server':
        protocol.send_FADD(tree, client)
    elif tree['kind'] != 0:
        hsh = chunk.register_chunk(hash.Hash(tree['unique_hash']), client)
        chunk.keep_chunk_alive(client, hsh)

        for instance in shared.climanager.clients[client.username]:
            if instance is not client:
                FADD(directory, 'server', filename, tree, instance)
    else:
        pass  # TODO: handle adding a directory with some content

    directory[filename] = tree
Пример #4
0
def FADD(directory, from_who, filename, tree, client):
    logger.debug('user {} adding {} from {}'
                 .format(client.username, tree['path'], from_who))

    if from_who == 'server':
        protocol.send_FADD(tree, client)
    elif tree['kind'] != 0:
        hsh = chunk.register_chunk(hash.Hash(tree['unique_hash']), client)
        chunk.keep_chunk_alive(client, hsh)

        for instance in shared.climanager.clients[client.username]:
            if instance is not client:
                FADD(directory, 'server', filename, tree, instance)
    else:
        pass  # TODO: handle adding a directory with some content

    directory[filename] = tree