From owner-freebsd-bugs@freebsd.org Mon Aug 22 21:40:12 2016 Return-Path: Delivered-To: freebsd-bugs@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8BF40BC2E25 for ; Mon, 22 Aug 2016 21:40:12 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2001:1900:2254:206a::16:76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7B46518BE for ; Mon, 22 Aug 2016 21:40:12 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from bugs.freebsd.org ([127.0.1.118]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id u7MLeCHq047369 for ; Mon, 22 Aug 2016 21:40:12 GMT (envelope-from bugzilla-noreply@freebsd.org) From: bugzilla-noreply@freebsd.org To: freebsd-bugs@FreeBSD.org Subject: [Bug 212065] fetch -r fails on a complete file, even with -S 12345 (OS version independent) Date: Mon, 22 Aug 2016 21:40:12 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: bin X-Bugzilla-Version: 10.3-RELEASE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: mandree@FreeBSD.org X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: freebsd-bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 22 Aug 2016 21:40:12 -0000 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D212065 Bug ID: 212065 Summary: fetch -r fails on a complete file, even with -S 12345 (OS version independent) Product: Base System Version: 10.3-RELEASE Hardware: Any OS: Any Status: New Severity: Affects Some People Priority: --- Component: bin Assignee: freebsd-bugs@FreeBSD.org Reporter: mandree@FreeBSD.org When fetch(1) is used to resume (-r) on a completely downloaded file, it erroneously fails with exit status 1. It should instead detect that conditi= on "file is complete and same size as on server" and exit with status 0 (=3D success). Adding to the -r option also a -S 12345 option, where -S is the same size as the file locally has, and as the server thinks its file is, does NOT help.= =20 Using "-m" is not an option if the file date isn't reported by the server. This bug has been reported on #bsdports (IRC) against 9.3 with portsnap, and can be verified without portsnap on 10.3-RELEASE-p7. Commented verbose fetch output on a hacked "portsnap fetch" downloading the initial snapshot as of today. First, see we have the file: $ ls -l *.tgz -rw-r--r-- 1 root wheel 74481909 Aug 22 23:03 80c30ef3c99969de68fad7d92a47c4e69cd6f1c8135504152d794c21305b1245.tgz Next, ask server for the size: $ fetch -s http://ec2-eu-west-1.portsnap.freebsd.org/s/80c30ef3c99969de68fad7d92a47c4e= 69cd6f1c8135504152d794c21305b1245.tgz ; echo $? 74481909 0 So, sizes match. File is complete. Now, try to resume the transfer, verbose mode: $ fetch -rvv http://ec2-eu-west-1.portsnap.freebsd.org/s/80c30ef3c99969de68fad7d92a47c4e= 69cd6f1c8135504152d794c21305b1245.tgz ; echo $? [...] ---> ec2-eu-west-1.portsnap.freebsd.org:80 looking up ec2-eu-west-1.portsnap.freebsd.org connecting to ec2-eu-west-1.portsnap.freebsd.org:80 requesting http://ec2-eu-west-1.portsnap.freebsd.org/s/80c30ef3c99969de68fad7d92a47c4e= 69cd6f1c8135504152d794c21305b1245.tgz >>> GET /s/80c30ef3c99969de68fad7d92a47c4e69cd6f1c8135504152d794c21305b1245= .tgz HTTP/1.1 >>> Host: ec2-eu-west-1.portsnap.freebsd.org >>> Accept: */* >>> User-Agent: fetch libfetch/2.0 >>> Range: bytes=3D74481909- >>> Connection: close >>>=20 <<< HTTP/1.1 416 Requested Range Not Satisfiable <<< Content-Type: text/html <<< Accept-Ranges: bytes <<< Content-Length: 389 <<< Connection: close content length: [389] <<< Date: Mon, 22 Aug 2016 21:07:00 GMT <<< Server: lighttpd/1.4.33 <<<=20 fetch: http://ec2-eu-west-1.portsnap.freebsd.org/s/80c30ef3c99969de68fad7d92a47c4e= 69cd6f1c8135504152d794c21305b1245.tgz: Requested Range Not Satisfiable 1 OOPS! See that -S doesn't help, same size as above: $ fetch -S 74481909 -r http://ec2-eu-west-1.portsnap.freebsd.org/s/80c30ef3c99969de68fad7d92a47c4e= 69cd6f1c8135504152d794c21305b1245.tgz ; echo $? fetch: http://ec2-eu-west-1.portsnap.freebsd.org/s/80c30ef3c99969de68fad7d92a47c4e= 69cd6f1c8135504152d794c21305b1245.tgz: Requested Range Not Satisfiable 1 NOTE: for proper robustness, fetch might want to issue a HEAD request to ob= tain the file size unconditionally when resuming, so as to be able to tell the condition "file shrunk on server" apart from "file has been completely downloaded". Other tools: * curl 7.50.1 from ports fails in a similar way, and to add insult to injur= y, wrongly concludes that the server did not support byte ranges when in fact = it does (but cannot start a download beyond the end of a file). * wget 1.18 also sees the 416 code from the server, but concludes "The file= is already fully retrieved; nothing to do." and exits with status 0. * lftp 4.7.3 with "get -c" does the right thing and exits silently if the f= ile is complete. --=20 You are receiving this mail because: You are the assignee for the bug.=