mirror of
https://github.com/landandair/Reticulum-Decentralized-File-Server.git
synced 2025-12-22 09:27:08 +00:00
- added a cancel function to the api
This commit is contained in:
@@ -107,6 +107,15 @@ class RNFSView(FlaskView):
|
||||
else:
|
||||
return 'Not Found'
|
||||
|
||||
@route('/cancel/<id>', methods=['GET'], endpoint='cancel')
|
||||
def cancel_request(self, id):
|
||||
"""cancel request to the network"""
|
||||
ret = self.info.cancel_request(id)
|
||||
if ret:
|
||||
return 'success'
|
||||
else:
|
||||
return 'Not Found'
|
||||
|
||||
|
||||
def start_server_thread(server_info):
|
||||
t = Thread(target=start_server, args=[server_info], daemon=True)
|
||||
|
||||
@@ -93,6 +93,15 @@ class RNSInterface:
|
||||
}
|
||||
return json.dumps(status)
|
||||
|
||||
def cancel_request(self, id: str):
|
||||
ret = False
|
||||
if id in self.hash_progress:
|
||||
self.hash_progress.pop(id)
|
||||
if id in self.desired_hash_translation_map:
|
||||
self.desired_hash_translation_map.pop(id)
|
||||
ret = True
|
||||
return ret
|
||||
|
||||
def load_allowed_peers(self, path):
|
||||
allowed_dest = []
|
||||
if path or not self.allow_all:
|
||||
@@ -251,7 +260,10 @@ class RNSInterface:
|
||||
request_id = response_rec.get_request_id()
|
||||
hash_str = self.request_id_to_hash[request_id]
|
||||
progress = response_rec.get_progress()
|
||||
|
||||
if hash_str in self.hash_progress:
|
||||
self.hash_progress[hash_str] = progress
|
||||
else:
|
||||
response_rec.link.teardown()
|
||||
|
||||
def service_desired_hash_list(self):
|
||||
"""Thread to service the desired hash dictionary"""
|
||||
|
||||
@@ -75,6 +75,10 @@ class ServerCommandState:
|
||||
self.cid_store.save_index()
|
||||
return ret
|
||||
|
||||
def cancel_request(self, id: str):
|
||||
ret = self.rns_interface.cancel_request(id)
|
||||
return ret
|
||||
|
||||
def updated_hash_callback(self, node_hash):
|
||||
"""Called when the cid storage has added any nodes from a dictionary(json file)"""
|
||||
node = self.cid_store.get_node_obj(node_hash)
|
||||
|
||||
Reference in New Issue
Block a user