OLD | NEW |
1 // Copyright (c) 2008-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2008-2009 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/mac_util.h" | 5 #include "base/mac_util.h" |
6 | 6 |
7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
8 | 8 |
9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 // Separate this component from the next one. | 233 // Separate this component from the next one. |
234 bundle_name += '/'; | 234 bundle_name += '/'; |
235 } | 235 } |
236 | 236 |
237 return FilePath(); | 237 return FilePath(); |
238 } | 238 } |
239 | 239 |
240 bool SetFileBackupExclusion(const FilePath& file_path, bool exclude) { | 240 bool SetFileBackupExclusion(const FilePath& file_path, bool exclude) { |
241 NSString* filePath = | 241 NSString* filePath = |
242 [NSString stringWithUTF8String:file_path.value().c_str()]; | 242 [NSString stringWithUTF8String:file_path.value().c_str()]; |
| 243 |
| 244 // If being asked to exclude something in a temp directory, just lie and say |
| 245 // it was done. TimeMachine will already ignore temp directories. This keeps |
| 246 // the temporary profiles used by unittests from being added to the exclude |
| 247 // list. Otherwise, as the list grows the bots slow down due to |
| 248 // reading/writes all the temporary profiles used over time. |
| 249 if ([filePath hasPrefix:@"/tmp/"] || |
| 250 [filePath hasPrefix:@"/var/tmp/"] || |
| 251 [filePath hasPrefix:@"/private/tmp/"] || |
| 252 [filePath hasPrefix:@"/private/var/tmp/"]) { |
| 253 return true; |
| 254 } |
| 255 |
243 NSURL* url = [NSURL fileURLWithPath:filePath]; | 256 NSURL* url = [NSURL fileURLWithPath:filePath]; |
244 // Note that we always set CSBackupSetItemExcluded's excludeByPath param | 257 // Note that we always set CSBackupSetItemExcluded's excludeByPath param |
245 // to true. This prevents a problem with toggling the setting: if the file | 258 // to true. This prevents a problem with toggling the setting: if the file |
246 // is excluded with excludeByPath set to true then excludeByPath must | 259 // is excluded with excludeByPath set to true then excludeByPath must |
247 // also be true when un-excluding the file, otherwise the un-excluding | 260 // also be true when un-excluding the file, otherwise the un-excluding |
248 // will be ignored. | 261 // will be ignored. |
249 bool success = | 262 bool success = |
250 CSBackupSetItemExcluded((CFURLRef)url, exclude, true) == noErr; | 263 CSBackupSetItemExcluded((CFURLRef)url, exclude, true) == noErr; |
251 if (!success) | 264 if (!success) |
252 LOG(WARNING) << "Failed to set backup excluson for file '" | 265 LOG(WARNING) << "Failed to set backup excluson for file '" |
(...skipping 20 matching lines...) Expand all Loading... |
273 << " but it was " | 286 << " but it was " |
274 << base::SysCFStringRefToUTF8(actual_type_ref) | 287 << base::SysCFStringRefToUTF8(actual_type_ref) |
275 << " instead"; | 288 << " instead"; |
276 return NULL; | 289 return NULL; |
277 } | 290 } |
278 | 291 |
279 return value; | 292 return value; |
280 } | 293 } |
281 | 294 |
282 } // namespace mac_util | 295 } // namespace mac_util |
OLD | NEW |