indexed_blob_model.py 文件源码

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

项目:farnsworth 作者: mechaphish 项目源码 文件源码
def create_or_get(cls, **kwargs):
        blob = kwargs.pop('blob')
        sha256 = kwargs.pop('sha256', hashlib.sha256(blob).hexdigest())
        try:
            with cls._meta.database.atomic():
                return cls.create(blob=blob, sha256=sha256, **kwargs), True
        except peewee.IntegrityError:
            try:
                return cls.get(sha256=sha256, **kwargs), False
            except cls.DoesNotExist: # this could happen with master-slave sync delay
                return None, False
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号