def delete_file(request: web.Request):
filename = request.match_info.get('name').strip()
filepath = os.path.join(config.args.storage, filename)
if filename in replication.dellog:
# We know this already
raise web.HTTPNotFound()
if not os.path.exists(filepath):
if not request.headers['User-Agent'].startswith('cockatiel/'):
logger.debug('File {} does not exist, but we will still propagate the deletion.'.format(filename))
replication.dellog.put(filename)
replication.queue_operation('DELETE', filename)
raise web.HTTPNotFound()
os.remove(filepath)
# TODO: Clean up now-empty dictionaries
logger.debug('Deleted file {}, scheduling replication.'.format(filename))
replication.dellog.put(filename)
replication.queue_operation('DELETE', filename)
return web.Response()
评论列表
文章目录