bug-wget
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug #62795] Distinguish between error codes


From: anonymous
Subject: [bug #62795] Distinguish between error codes
Date: Thu, 21 Jul 2022 17:05:40 -0400 (EDT)

URL:
  <https://savannah.gnu.org/bugs/?62795>

                 Summary: Distinguish between error codes
                 Project: GNU Wget
               Submitter: None
               Submitted: Thu 21 Jul 2022 09:05:39 PM UTC
                Category: Feature Request
                Severity: 3 - Normal
                Priority: 5 - Normal
                  Status: None
                 Privacy: Public
             Assigned to: None
         Originator Name: 
        Originator Email: 
             Open/Closed: Open
                 Release: 1.20
         Discussion Lock: Any
        Operating System: GNU/Linux
         Reproducibility: Every Time
           Fixed Release: None
         Planned Release: None
              Regression: No
           Work Required: None
          Patch Included: No


    _______________________________________________________

Follow-up Comments:


-------------------------------------------------------
Date: Thu 21 Jul 2022 09:05:39 PM UTC By: Anonymous
wget does not appear to distinguish between a non-zero error code due to
download issues versus a non-zero error code due to an existing and complete
file.

This means there's no simple way for a script to verify whether the download
was successful without having to re-download the file, regardless of whether
it already exists.

For example:

wget --quiet --content-disposition -nc -c
https://api.adoptium.net/v3/binary/latest/17/ga/linux/arm/jre/hotspot/normal/eclipse
-O jre.tar.gz
echo $?

wget --quiet --content-disposition -nc -c
https://api.adoptium.net/v3/binary/latest/17/ga/linux/arm/jre/hotspot/normal/eclipse
-O jre.tar.gz
echo $?

Produces:

0
1

Checking to see if the file exists won't work. The file could be 0 bytes or
could be a different size/version altogether. We don't know the file size in
advance. We could use --spider and grep for the content-length (or cURL to
grab HTTP headers), but that makes additional superfluous HTTP requests and
adds needless complexity to scripts.

Instead, how about a new flag to change the error code to 0 if the file exists
and is the same size as reported on the server:

wget --quiet --content-disposition --exists-ok -nc -c
https://api.adoptium.net/v3/binary/latest/17/ga/linux/arm/jre/hotspot/normal/eclipse
-O jre.tar.gz
echo $?

wget --quiet --content-disposition --exists-ok -nc -c
https://api.adoptium.net/v3/binary/latest/17/ga/linux/arm/jre/hotspot/normal/eclipse
-O jre.tar.gz
echo $?

Would produce:

0
0

We only care that the file is the same, not whether it was downloaded
successfully. (Arguably this would mean comparing hashcodes of the two files,
but comparing file sizes is usually sufficient.)







    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?62795>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]