s3file.py 文件源码

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

项目:python-s3-cache 作者: vincetse 项目源码 文件源码
def close(self):
        """On closing the file, copy it back to s3 if it was opened for
        writing/appending.

        :rtype: int
        :return: the number of bytes written
        """
        self.log("closing local cache file(" + self.tmppath + ")")
        self.file.close()
        bytes_written = 0
        if 'w' in self.mode or 'a' in self.mode:
            self.log("writing updated cache file contents to S3")
            k = Key(self.mgr.bucket, self.path)
            try:
                bytes_written = k.set_contents_from_filename(self.tmppath)
            except AttributeError as err:
                self.log(str(err))
                raise
        if not self.mgr.caching:
            # remove the local copy if caching is turned off
            self.remove_cached()
        return bytes_written
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号