Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(533)

Unified Diff: content/browser/download/base_file.cc

Issue 10831302: Download resumption - Preliminary (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fixed content unit tests. Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/download/base_file.cc
diff --git a/content/browser/download/base_file.cc b/content/browser/download/base_file.cc
index cc7871fcedde3d1a34ba8488651b4e4f96a7b20a..7015425cf437853baffb31880fa0b6249f7d60d8 100644
--- a/content/browser/download/base_file.cc
+++ b/content/browser/download/base_file.cc
@@ -515,6 +515,19 @@ net::Error BaseFile::Open() {
file_stream_->SetBoundNetLogSource(bound_net_log_);
}
+ int64 file_size = file_stream_->SeekSync(net::FROM_END, 0);
+ if (file_size > bytes_so_far_) {
+ // The file is larger than we expected.
+ // This is OK, as long as we don't use the extra.
+ // Truncate the file.
+ int64 truncate_result = file_stream_->Truncate(bytes_so_far_);
+ DCHECK_EQ(bytes_so_far_, truncate_result);
+ } else if (file_size < bytes_so_far_) {
+ // The file is shorter than we expected. Our hashes won't be valid.
+ // This will map to a generic 'FAIL' interrupt reason.
+ return LOG_ERROR("Seek", 1); // net::ERR_UNEXPECTED.
+ }
+
return net::OK;
}

Powered by Google App Engine
This is Rietveld 408576698