vfs_local.py 文件源码

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

项目:obnam 作者: obnam-mirror 项目源码 文件源码
def _create_tempfile(self, pathname):  # pragma: no cover
        path = self.join(pathname)
        dirname = os.path.dirname(path)
        if not os.path.exists(dirname):
            tracing.trace('os.makedirs(%s)' % dirname)
            try:
                os.makedirs(dirname, mode=obnamlib.NEW_DIR_MODE)
            except OSError as e:  # pragma: no cover
                # This avoids a race condition: another Obnam process
                # may have created the directory between our check and
                # creation attempt. If so, we ignore it. As long as
                # the directory exists, all's good.
                if e.errno != errno.EEXIST:
                    raise

        fd, tempname = tempfile.mkstemp(dir=dirname)
        os.fchmod(fd, obnamlib.NEW_FILE_MODE)
        os.close(fd)
        f = self.open(tempname, 'wb')
        f.close()
        return tempname
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号