Ejemplo n.º 1
0
def synceds_delete():
    # Delete a mirror
    sid = int(request.form.get('id'))
    s = WorkFolder(sid)
    if s.exists() and s.get_owner().get_username() == user.get_username():
        s.delete(False)
        abort(200)
    else:
        abort(403)
Ejemplo n.º 2
0
def synced_generate_invite(sid):
    user = require_user()
    s = WorkFolder(sid)
    #app.logger.error('User: %s, existance: %s, owner: %s', user.get_username(), str(s.exists()), s.get_owner().get_username())
    if s.exists() and s.get_owner().get_username() == user.get_username():
        random_id = random.randint(100, 2000000)
        current_upload_keys.append({ 'id': random_id, 'time': datetime.datetime.now(), 'synced_id': sid, 'user': user })
        return str(random_id)
    else:
        abort(403)
Ejemplo n.º 3
0
def synced_name():
    user = require_user()
    name = request.form.get('name', None)
    sid = int(request.form.get('id'))
    s = WorkFolder(sid)
    if name != None and s.exists() and s.get_owner().get_username() == user.get_username():
        # Change name
        s.change_name(name)
        abort(200)
    else:
        abort(403)
Ejemplo n.º 4
0
def synced_invite(iid):
    prune_old_upload_keys()
    invite = [i for i in current_upload_keys if i['id'] == iid]
    if invite:
        r_invite = invite[0]
        s = WorkFolder(r_invite['synced_id'])
        user = r_invite['user']
        if s.exists() and s.get_owner().get_username() == user.get_username():
            fingerprint = get_fingerprint() 
            manager_path, _ = os.path.split(request.url_root[:-1])
            server = os.path.split(manager_path)[0].replace('http://', '')
            server = server.replace('https://','')
            xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + \
                  "<sparkleshare>\n" + \
                  "  <invite>\n" + \
                  "    <address>ssh://" + user.get_username() + "@" + server + "/</address>\n" + \
                  "    <remote_path>/var/nublic/work-folders/" + str(s.get_id()) + "</remote_path>\n" + \
                  "    <fingerprint>" + str(fingerprint) + "</fingerprint>\n" + \
                  "    <accept_url>https://" + server + "/manager/server/synced-upload-key/" + str(iid) + "</accept_url>\n" + \
                  "  </invite>\n" + \
                  "</sparkleshare>"
            return xml
    else:
        abort(403)