'name is too long' (tarfile, python 2.2, Debian Woody)

Discussion in 'Python' started by Lars Behrens, Aug 20, 2003.

  1. Lars Behrens

    Lars Behrens Guest

    Hi, Pythonistas!

    I'm quite new to Python and have a problem with a simple backup script.

    This code:

    tar = tarfile.open('/home/lars/test.tar.gz', 'w:gz')
    tar.addfile('/home/lars')

    brings up the following error message:

    **********************************************************************
    /usr/lib/python2.2/site-packages/tarfile.py in addfile(self, tarinfo,
    fileobj)
    1289
    1290 if not prefix or len(name) > LENGTH_NAME:
    -> 1291 raise ValueError, "name is too long (>%d)" \
    1292 % (LENGTH_NAME)
    1293

    ValueError: name is too long (>100)
    **********************************************************************

    Any hints for me?

    Thanks in advance
    Lars
     
    Lars Behrens, Aug 20, 2003
    #1
    1. Advertisements

  2. The standard tar format allows only names (i.e. complete path) of 100
    characters. So in your '/home/lars' are names (fully expanded) which are
    longer.
    Please have a look at the documentation of tarfile, there is an option
    to store extended path names. Most other tar programs (like gnu-tar)
    support these, as well.


    --
    Helmut Jarausch

    Lehrstuhl fuer Numerische Mathematik
    RWTH - Aachen University
    D 52056 Aachen, Germany
     
    Helmut Jarausch, Aug 20, 2003
    #2
    1. Advertisements

  3. Lars Behrens

    Peter Hansen Guest

    Perhaps this is a sign that the problem was really somewhere else. What
    you say you did is not likely to have solved the problem given the
    documentation above. It says that setting tar.posix to *False* would
    allow longer path names, not the other way around. If you think you
    just got longer names to work and your problems went away, you
    are probably missing something here...

    -Peter
     
    Peter Hansen, Aug 20, 2003
    #3
  4. Lars Behrens

    Lars Behrens Guest

    Sorry, a typo, of course I set tar.posix to false.
    Mea culpa...

    Cheerz Lars
     
    Lars Behrens, Aug 20, 2003
    #4
  5. The fact that it worked this time seems pure chance to me, it is likely to
    fail in the future. For backup purposes you should definitely set
    tar.posix=False to enable long pathnames in your tar file.
    tarfile.GNUTYPE_LONGNAME is a constant for internal use only. You don't
    need to handle long pathnames yourself. I admit that setting an attribute
    to False to turn on a feature may seem a bit cumbersome, but once you got
    used to it it feels okay ;-)
    tarfile creates POSIX compliant tar files by default because they are more
    portable. If you just want to make backups for your personal use you don't
    need to bother, so turn off the POSIX mode.
     
    Lars Gustaebel, Aug 20, 2003
    #5
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.