handlers.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:cockatiel 作者: raphaelm 项目源码 文件源码
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()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号