Tar module issue

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • chaica

    #1

    Tar module issue

    Hi,

    chaica@desktop chaica $ python
    Python 2.4 (#1, Jan 10 2005, 22:28:10)
    [GCC 3.2.3 20030422 (Gentoo Linux 1.4 3.2.3-r3, propolice)] on linux2

    I'm using tarfile module to create an archive. For my example I'm using
    Amsn file and directory tree.
    My variables are like these ones:
    path = /home/chaica/downloads/amsn-0_94/skins/Tux/smileys/shades.gif
    fileName = amsn-0_94/skins/Tux/smileys/shades.gif
    tar.add( path, fileName )

    and while untaring my archive with tar jxvf I've random errors :
    tar: amsn-0_94/lang/genlangfiles.c: Cannot hard link to
    `amsn-0_94/lang/genlangfiles.c' : No such file or directory

    I checked google and saw that errors like these ones could occur when
    you use global path while taring, but I'm not, using fileName which is
    local.

    Thx

    --
    chaica <lordchaica@fre e.fr>

  • Russell Bungay

    #2
    Re: Tar module issue

    Hello,
    [color=blue]
    > I'm using tarfile module to create an archive. For my example I'm using
    > Amsn file and directory tree.
    > My variables are like these ones:
    > path = /home/chaica/downloads/amsn-0_94/skins/Tux/smileys/shades.gif
    > fileName = amsn-0_94/skins/Tux/smileys/shades.gif
    > tar.add( path, fileName )
    > and while untaring my archive with tar jxvf I've random errors :
    > tar: amsn-0_94/lang/genlangfiles.c: Cannot hard link to
    > `amsn-0_94/lang/genlangfiles.c' : No such file or directory
    > I checked google and saw that errors like these ones could occur when
    > you use global path while taring, but I'm not, using fileName which is
    > local.[/color]

    I used tarfile for the first time at the weekend and noticed one thing
    that may help. I don't know if it is a specific solution to your
    problem, but it might be worth a try.

    I noticed that if I didn't explicitly close the tarfile with tar.close()
    after I had added the files, the resultant file would sometimes not be
    written properly (even with completed execution of the whole script).
    Explicitly closing the file would make these problems go away.

    I hope that helps,

    R

    Comment

    • chaica

      #3
      Re: Tar module issue

      Thx for your response.
      The fact is that I use tar.close() at the end of my code. This is really
      a random behaviour cause with an archive which has a short directory
      tree, I don't have this kind of beahavior and the archive works.

      thx


      On Mon, 2005-02-07 at 13:01 +0000, Russell Bungay wrote:[color=blue]
      > Hello,
      >[color=green]
      > > I'm using tarfile module to create an archive. For my example I'm using
      > > Amsn file and directory tree.
      > > My variables are like these ones:
      > > path = /home/chaica/downloads/amsn-0_94/skins/Tux/smileys/shades.gif
      > > fileName = amsn-0_94/skins/Tux/smileys/shades.gif
      > > tar.add( path, fileName )
      > > and while untaring my archive with tar jxvf I've random errors :
      > > tar: amsn-0_94/lang/genlangfiles.c: Cannot hard link to
      > > `amsn-0_94/lang/genlangfiles.c' : No such file or directory
      > > I checked google and saw that errors like these ones could occur when
      > > you use global path while taring, but I'm not, using fileName which is
      > > local.[/color]
      >
      > I used tarfile for the first time at the weekend and noticed one thing
      > that may help. I don't know if it is a specific solution to your
      > problem, but it might be worth a try.
      >
      > I noticed that if I didn't explicitly close the tarfile with tar.close()
      > after I had added the files, the resultant file would sometimes not be
      > written properly (even with completed execution of the whole script).
      > Explicitly closing the file would make these problems go away.
      >
      > I hope that helps,
      >
      > R[/color]
      --
      chaica <lordchaica@fre e.fr>

      Comment

      • Eddie Corns

        #4
        Re: Tar module issue

        I don't have the original query any more but I think your problem is related
        to mixing absolute and relative file paths. That is the filenames themselves,
        I think I recall in your original message you were mixing up the idea of
        global variables in your code versus the filenames stored in the TAR archive.

        When tar restores files it will either be doing them as relative paths
        (directory + filename) or absolute paths, I think relative is the default.
        This is relative to where you are now when you extract NOT where you were when
        you archived them. I think there may be extra confusion to do with the way
        tar stores hard links What might be happening is that some paths are actually
        links to other files, you would need to figure out how tar is dealing with
        this - is it converting links back to relative paths (unlikely I suspect)?
        Either way it might be trying to create a link to a file that either doesn't
        exist on the system you are restoring to or not from the directory where you
        now are.

        I hope that makes sense.

        Eddie

        Comment

        Working...