bugGNU Wget - Bugs: bug #61755, --unlink doesn't

 
 

bug #61755: --unlink doesn't

Submitter:  None
Submitted:  Mon 03 Jan 2022 03:26:41 AM UTC
   
 
Category:  Program Logic Severity:  3 - Normal
Priority:  5 - Normal Status:  Fixed
Privacy:  Public Assigned to:  rockdaboot
Originator Name:  /df Originator Email:  -email is unavailable-
Open/Closed:  Closed Release:  trunk
Operating System:  GNU/Linux Reproducibility:  None
Fixed Release:  trunk Planned Release:  None
Regression:  None Work Required:  None
Patch Included:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Sun 09 Jan 2022 06:01:08 PM UTC, comment #4: 

Just pushed a fix for wget as well.

Tim Ruehsen <rockdaboot>
Group administrator
Sun 09 Jan 2022 12:57:58 PM UTC, comment #3: 

Fixed this for Wget2 now. I'll take a look at wget later.

Tim Ruehsen <rockdaboot>
Group administrator
Sun 09 Jan 2022 11:55:23 AM UTC, comment #2: 

Apparently the suspect code is here:

https://git.savannah.gnu.org/cgit/wget.git/tree/src/http.c#n2528

unlink_requested is supposed to be set when --unlink is passed.


static uerr_t
open_output_stream (struct http_stat *hs, int count, FILE **fp)
{
...
# define FOPEN_BIN_FLAG true
...
  /* Open the local file.  */
  if (!output_stream)
    {
      mkalldirs (hs->local_file);
      if (opt.backups)
        rotate_backups (hs->local_file);
      if (hs->restval)
        {
...
          *fp = fopen (hs->local_file, "ab");
...
        }
      else if (ALLOW_CLOBBER || count > 0)
        {
          if (opt.unlink_requested && file_exists_p (hs->local_file, NULL))
            {
              if (unlink (hs->local_file) < 0)
                {
                  logprintf (LOG_NOTQUIET, "%s: %s\n", hs->local_file,
                             strerror (errno));
                  return UNLINKERR;
                }
            }


Anonymous
Sun 09 Jan 2022 11:23:47 AM UTC, comment #1: 

Thanks,
I confirm this issue is reproducible on latest wget and wget2.

Tim Ruehsen <rockdaboot>
Group administrator
Mon 03 Jan 2022 03:26:41 AM UTC, original submission:  

The '--unlink' option is described like this:


       --unlink
           Force Wget to unlink file instead of clobbering existing file. This
           option is useful for downloading to the directory with hardlinks.


So with existing 'file', 'wget --unlink ... o file' should work like 'unlink file; 'wget ... o file', surely. It doesn't in the example below, which could be disastrous if relying on the documented behaviour.


$ wget --version
GNU Wget 1.21 built on linux-gnu.

-cares +digest -gpgme +https +ipv6 +iri +large-file -metalink +nls
+ntlm +opie +psl +ssl/openssl

Wgetrc:
    /etc/wgetrc (system)
Locale:
    /usr/share/locale
Compile:
    gcc -DHAVE_CONFIG_H -DSYSTEM_WGETRC="/etc/wgetrc"
    -DLOCALEDIR="/usr/share/locale" -I. -I../../src -I../lib
    -I../../lib -Wdate-time -D_FORTIFY_SOURCE=2 -DHAVE_LIBSSL -DNDEBUG
    -g -O2 -fdebug-prefix-map=/build/wget-GywCSU/wget-1.21=.
    -fstack-protector-strong -Wformat -Werror=format-security
    -DNO_SSLv2 -D_FILE_OFFSET_BITS=64 -g -Wall
Link:
    gcc -DHAVE_LIBSSL -DNDEBUG -g -O2
    -fdebug-prefix-map=/build/wget-GywCSU/wget-1.21=.
    -fstack-protector-strong -Wformat -Werror=format-security
    -DNO_SSLv2 -D_FILE_OFFSET_BITS=64 -g -Wall -Wl,-Bsymbolic-functions
    -Wl,-z,relro -Wl,-z,now -lpcre2-8 -luuid -lidn2 -lssl -lcrypto -lz
    -lpsl ftp-opie.o openssl.o http-ntlm.o ../lib/libgnu.a

Copyright (C) 2015 Free Software Foundation, Inc.
Licence GPLv3+: GNU GPL version 3 or later
<http://www.gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Originally written by Hrvoje Niksic <hniksic@xemacs.org>.
Please send bug reports and questions to <bug-wget@gnu.org>.
$ echo > foo
$ ln foo foobar
$ ls -l foo*
-rw-rw-r-- 2 df df 1 Jan  3 03:10 foo
-rw-rw-r-- 2 df df 1 Jan  3 03:10 foobar
$ wget --unlink -O foobar "$url"
...
Length: 11372 (11K) [image/png]
...
2022-01-03 03:11:47 (473 B/s) - ‘foobar’ saved [11372/11372]

$ ls -l foo*
-rw-rw-r-- 2 df df 11372 Oct  1  2012 foo
-rw-rw-r-- 2 df df 11372 Oct  1  2012 foobar
$


Expected result:

$ ls -l foo*
-rw-rw-r-- 2 df df 1 Jan  3 03:10 foo
-rw-rw-r-- 2 df df 11372 Oct  1  2012 foobar
$


Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rockdaboot (Posted a comment)
  • -email is unavailable- added by raysatiro
  • -email is unavailable- added by None (Submitted the item)
  •  

    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-01-09 rockdaboot StatusConfirmed Fixed
        Assigned toNone rockdaboot
        Open/ClosedOpen Closed
        Fixed ReleaseNone trunk
    2022-01-09 rockdaboot StatusNone Confirmed
    2022-01-03 raysatiro Carbon-Copy- Added -email is unavailable-

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code