@@ -692,6 +692,24 @@ public function testDownloadRange()
692
692
$ filesize - 3 ,
693
693
$ filesize - 2 ,
694
694
$ filesize - 1 ,
695
+
696
+ // A partial temporary file having the exact same file size as the complete source file should only
697
+ // occur under certain circumstances (almost never). When the download successfully completed, the
698
+ // temporary file should have been moved to the download destination save path. However, it is possible
699
+ // that a larger file download was interrupted after which the source file was updated and now has the
700
+ // exact same file size as the partial temporary. When resuming the download, the range is now
701
+ // unsatisfiable as the first byte position exceeds the available range. The entire file should be
702
+ // downloaded again.
703
+ $ filesize - 0 ,
704
+
705
+ // A partial temporary file having a larger file size than the complete source file should only occur
706
+ // under certain circumstances. This is possible when a download was interrupted after which the source
707
+ // file was updated with a smaller file. When resuming the download, the range is now unsatisfiable as
708
+ // the first byte position exceeds the the available range. The entire file should be downloaded again.
709
+ $ filesize + 1 ,
710
+ $ filesize + 2 ,
711
+ $ filesize + 3 ,
712
+
695
713
) as $ length ) {
696
714
697
715
$ source = Test::TEST_URL ;
@@ -749,10 +767,12 @@ public function testDownloadRange()
749
767
$ this ->assertEquals ($ expected_bytes_downloaded , $ bytes_downloaded );
750
768
}
751
769
$ this ->assertEquals ($ expected_http_status_code , $ curl ->httpStatusCode );
752
- $ this ->assertEquals ($ filesize , filesize ($ destination ));
753
770
754
- unlink ($ destination );
755
- $ this ->assertFalse (file_exists ($ destination ));
771
+ if (!$ curl ->error ) {
772
+ $ this ->assertEquals ($ filesize , filesize ($ destination ));
773
+ unlink ($ destination );
774
+ $ this ->assertFalse (file_exists ($ destination ));
775
+ }
756
776
}
757
777
758
778
// Remove server file.
0 commit comments