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

Unified Diff: chrome/browser/download/download_util.cc

Issue 6905049: Detect removed files and reflect the state in chrome://downloads and the download shelf (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 9 years, 8 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: chrome/browser/download/download_util.cc
diff --git a/chrome/browser/download/download_util.cc b/chrome/browser/download/download_util.cc
index 05751ded1ff230e8b028cb2f9f6e1809025a5dfa..41bbd1ed6245b5d9891d08609bc1d1f4948c4018 100644
--- a/chrome/browser/download/download_util.cc
+++ b/chrome/browser/download/download_util.cc
@@ -664,7 +664,22 @@ DictionaryValue* CreateDownloadItemValue(DownloadItem* download, int id) {
if (download->safety_state() == DownloadItem::DANGEROUS) {
file_value->SetString("state", "DANGEROUS");
} else {
- file_value->SetString("state", "COMPLETE");
+ bool path_exists = true;
Paweł Hajdan Jr. 2011/04/27 08:53:30 It seems like you're checking whether a path exist
+#if defined(OS_WIN)
+ if (GetFileAttributes(
+ download->GetTargetFilePath().value().c_str()) ==
+ INVALID_FILE_ATTRIBUTES)
+ path_exists = false;
+#elif defined(OS_POSIX)
+ if (access(download->GetTargetFilePath().value().c_str(), F_OK) != 0)
+ path_exists = false;
+#else
Paweł Hajdan Jr. 2011/04/27 08:53:30 A "dangling else" like that is generally dangerous
+#endif
+ if (path_exists) {
Paweł Hajdan Jr. 2011/04/27 08:53:30 nit: It's probably cleaner to use a ternary operat
+ file_value->SetString("state", "COMPLETE");
+ } else {
+ file_value->SetString("state", "REMOVED");
+ }
}
}

Powered by Google App Engine
This is Rietveld 408576698