#162232 parchive: Bad handling of symbolic linked output files.

Package:
parchive
Source:
parchive
Description:
Use PAR files to reconstruct missing parts of multi-part archives
Submitter:
Date:
2005-07-18 03:26:29 UTC
Severity:
normal
#162232#5
Date:
2002-09-25 01:47:04 UTC
From:
To:
Parchive doesn't always deal with symbolic links well (or the way I'd
expect), specifically when the output files exist already as symbolic
links.  The worst case is when you link the output to a file that doesn't
exist.  It fails to write output, and it deletes the links.

It works fine when input files are symbolic links.

kyle@firebee ~/partest/inlink $ ls -l
total 8
-rw-------    1 kyle     kyle           17 Sep 24 19:29 file1
-rw-------    1 kyle     kyle           16 Sep 24 19:29 file2
lrwxrwxrwx    1 kyle     kyle            5 Sep 24 19:29 input1 -> file1
lrwxrwxrwx    1 kyle     kyle            5 Sep 24 19:29 input2 -> file2
kyle@firebee ~/partest/inlink $ parchive a -n2 out.par input*
Adding to out.par
  input1                                   - OK
  input2                                   - OK


Creating PAR volumes:
0%100%
  out.p02                                  - OK
  out.p01                                  - OK
kyle@firebee ~/partest/inlink $ ls -l
total 20
-rw-------    1 kyle     kyle           17 Sep 24 19:29 file1
-rw-------    1 kyle     kyle           16 Sep 24 19:29 file2
lrwxrwxrwx    1 kyle     kyle            5 Sep 24 19:29 input1 -> file1
lrwxrwxrwx    1 kyle     kyle            5 Sep 24 19:29 input2 -> file2
-rw-------    1 kyle     kyle          249 Sep 24 19:42 out.p01
-rw-------    1 kyle     kyle          249 Sep 24 19:42 out.p02
-rw-------    1 kyle     kyle          232 Sep 24 19:42 out.par

==============================
If you link the output files to files that don't exist, parchive complains
that the files exist, and DELETES THE LINKS.  Ouch!

I think it should create the missing files, and write to them.  I wanted to
do this so that I could generate output on a drive different from my input.

kyle@firebee ~/partest/outlink-gone $ ls -l
total 8
-rw-------    1 kyle     kyle           17 Sep 24 19:30 input1
-rw-------    1 kyle     kyle           16 Sep 24 19:30 input2
lrwxrwxrwx    1 kyle     kyle            8 Sep 24 19:41 out.p01 -> missing1
lrwxrwxrwx    1 kyle     kyle            8 Sep 24 19:41 out.p02 -> missing2
kyle@firebee ~/partest/outlink-gone $ parchive a -n2 out.par input*
Adding to out.par
  input1                                   - OK
  input2                                   - OK


Creating PAR volumes:
0%WRITE ERROR: File exists
  out.p02                                  - FAILED
  out.p01                                  - FAILED

Errors occurred.

kyle@firebee ~/partest/outlink-gone $ ls -l
total 12
-rw-------    1 kyle     kyle           17 Sep 24 19:30 input1
-rw-------    1 kyle     kyle           16 Sep 24 19:30 input2
-rw-------    1 kyle     kyle          232 Sep 24 19:42 out.par

==============================
If you link to /dev/null (a file that does exist), it'll skip over those
output files.  It's not shown here, but if you ask for more output files,
it'll go ahead and make the extra files, skipping the linked ones.  That's
fine with me, since I was trying to skip making those files anyway.

If you try this with existing plain files, you can see that it doesn't try
to write to them.  Maybe it should; I'm not sure.

kyle@firebee ~/partest/outlink-null $ ls -l
total 8
-rw-------    1 kyle     kyle           17 Sep 24 19:31 input1
-rw-------    1 kyle     kyle           16 Sep 24 19:31 input2
lrwxrwxrwx    1 kyle     kyle            9 Sep 24 19:30 out.p01 -> /dev/null
lrwxrwxrwx    1 kyle     kyle            9 Sep 24 19:30 out.p02 -> /dev/null
kyle@firebee ~/partest/outlink-null $ parchive a -n2 out.par input*
Adding to out.par
  input1                                   - OK
  input2                                   - OK


Creating PAR volumes:
      WRITE ERROR: out.p02: File exists
  out.p02                                  - FAILED
      WRITE ERROR: out.p01: File exists
  out.p01                                  - FAILED
0%100%

Errors occurred.

kyle@firebee ~/partest/outlink-null $ ls -l
total 12
-rw-------    1 kyle     kyle           17 Sep 24 19:31 input1
-rw-------    1 kyle     kyle           16 Sep 24 19:31 input2
lrwxrwxrwx    1 kyle     kyle            9 Sep 24 19:30 out.p01 -> /dev/null
lrwxrwxrwx    1 kyle     kyle            9 Sep 24 19:30 out.p02 -> /dev/null
-rw-------    1 kyle     kyle          232 Sep 24 19:42 out.par

#162232#10
Date:
2002-09-25 02:26:50 UTC
From:
To:
    Hello Kyle,

    Erm, yes.  Good observations.  Specific comments below.

[...]

    Agreed.  Note that you can easily do something like:

parchive a -n2 /some/other/directory/out.par input*

and that's probably a better idea than trying to pre-symlink each file, but
not following symlinks is still broken, IMO.

    I'd say that it should do the same thing that it does with existing
regular files (not write to them, IIRC, although I don't know about the case
where some files exist and others don't [I can't test this right now]) for
consistency's sake.  I'm prone to messing up my parchive add commands, so
I'm rather happy that parchive by default doesn't write to files unless
everything is ok.

    Thanks for pointing this out.  I'll take a closer look and confer with
upstream.  I'm currently severely swamped (academically and at work) for the
next few weeks though, so a resolution may take a little longer than normal.

Rene