예제 #1
0
def test_archive_shared_path(aaa):
    """Archive a shared path and return a zip file"""
    t.root_dir = "/tmp/test"
    aaa.user_is_anonymous = True
    prep_folder()
    r = t.archive_path("/tmp/test")
    assert r.startswith("/tmp/test")
    assert r.endswith(".tar.gz")
    assert path.exists(r)
    assert path.exists(r)
    assert TarFile.open(r).getnames() == ["test", "test/folder", "test/file"]
예제 #2
0
def list_path(path='.'):
    """Return a list of files in a path if permitted
    """
    try:
        real_path = protect_path(path)
    except IOError:
        abort(403, PATH_ERROR)
    if request.GET.get('format', 'raw').strip() == 'zip':
        print('got zip')
        archive = archive_path(real_path)
        return list_dir(archive)

    return list_dir(real_path)
예제 #3
0
def list_shared(user, uid, path='.'):
    """If the path is a file: return it's content

    if the path is a folder: return a list of files in the folder

    if parameter 'format' is specified return the path in the
    specified format (zip only for now)
    """
    real_shared_path = get_path_from_uid(user, uid)
    # print(real_shared_path)
    permitted = join_path(root_dir, real_shared_path)
    try:
        real_path = get_real_path(permitted, path)
    except IOError:
        abort(403, PATH_ERROR)
    # print("getting {}".format(real_path))
    print(request.GET.keys())
    if request.GET.get('format', 'raw').strip() == 'zip':
        print('got zip')
        archive = archive_path(real_path)
        return list_dir(archive)

    return list_dir(real_path)