Index: net/base/upload_data.cc |
diff --git a/net/base/upload_data.cc b/net/base/upload_data.cc |
index 0045409bf5479318de97b12ae20da9f18f86d4b7..87b6426e6e47db81242f3074bd62f9f50813fee4 100644 |
--- a/net/base/upload_data.cc |
+++ b/net/base/upload_data.cc |
@@ -23,11 +23,12 @@ uint64 UploadData::Element::GetContentLength() const { |
DCHECK(type_ == TYPE_FILE); |
- // TODO(darin): This size calculation could be out of sync with the state of |
- // the file when we get around to reading it. We should probably find a way |
- // to lock the file or somehow protect against this error condition. |
+ expected_file_length_ = 0; |
- int64 length = 0; |
+ if (!file_util::PathIsReadable(file_path_)) |
darin (slow to review)
2010/01/12 07:57:45
on windows, it might be nice to combine these two
agl
2010/01/25 14:14:09
PathIsReadable no longer obtains a file handle, so
|
+ return 0; |
+ |
+ int64 length; |
if (!file_util::GetFileSize(file_path_, &length)) |
return 0; |
@@ -35,7 +36,9 @@ uint64 UploadData::Element::GetContentLength() const { |
return 0; // range is beyond eof |
// compensate for the offset and clip file_range_length_ to eof |
- return std::min(length - file_range_offset_, file_range_length_); |
+ expected_file_length_ = std::min(length - file_range_offset_, |
+ file_range_length_); |
+ return expected_file_length_; |
} |
} // namespace net |