Chromium Code Reviews| 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"); |
| + } |
| } |
| } |