rpath.py 文件源码

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

项目:rdiff-backup 作者: sol1 项目源码 文件源码
def rename(rp_source, rp_dest):
    """Rename rp_source to rp_dest"""
    assert rp_source.conn is rp_dest.conn
    log.Log(lambda: "Renaming %s to %s" % (rp_source.path, rp_dest.path), 7)
    if not rp_source.lstat(): rp_dest.delete()
    else:
        if rp_dest.lstat() and rp_source.getinode() == rp_dest.getinode() and \
                rp_source.getinode() != 0:
            log.Log("Warning: Attempt to rename over same inode: %s to %s"
                    % (rp_source.path, rp_dest.path), 2)
            # You can't rename one hard linked file over another
            rp_source.delete()
        else:
            try:
                rp_source.conn.os.rename(rp_source.path, rp_dest.path)
            except OSError, error:
                # XXX errno.EINVAL and len(rp_dest.path) >= 260 indicates
                # pathname too long on Windows
                if error.errno != errno.EEXIST:
                    log.Log("OSError while renaming %s to %s"
                            % (rp_source.path, rp_dest.path), 1)
                    raise

                # On Windows, files can't be renamed on top of an existing file
                rp_source.conn.os.chmod(rp_dest.path, 0700)
                rp_source.conn.os.unlink(rp_dest.path)
                rp_source.conn.os.rename(rp_source.path, rp_dest.path)

        rp_dest.data = rp_source.data
        rp_source.data = {'type': None}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号