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

Unified Diff: webkit/fileapi/obfuscated_file_util.cc

Issue 8728029: Update mtime of directory when containee changed. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: '' Created 9 years, 1 month 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: webkit/fileapi/obfuscated_file_util.cc
diff --git a/webkit/fileapi/obfuscated_file_util.cc b/webkit/fileapi/obfuscated_file_util.cc
index 385393b9db01ff630b29dd345acb4510d95b0bc8..5c9a0b5f79bf4ad04e002ae205ae343e196bc43b 100644
--- a/webkit/fileapi/obfuscated_file_util.cc
+++ b/webkit/fileapi/obfuscated_file_util.cc
@@ -92,6 +92,14 @@ void UpdatePathQuotaUsage(
type, growth);
}
+void TouchDirectory(fileapi::FileSystemDirectoryDatabase* db,
+ fileapi::FileSystemDirectoryDatabase::FileId dir_id) {
+ DCHECK(db);
+ // Do nothing for root directory.
ericu 2011/11/30 19:16:04 Why do you special-case the root? My Linux box do
tzik 2011/12/01 16:28:46 It is just to keep consistency to current implemen
ericu 2011/12/05 21:43:50 That is incorrect. Look at FileSystemDirectoryDat
+ if (dir_id && !db->UpdateModificationTime(dir_id, base::Time::Now()))
+ NOTREACHED();
+}
+
const FilePath::CharType kLegacyDataDirectory[] = FILE_PATH_LITERAL("Legacy");
const FilePath::CharType kTemporaryDirectoryName[] = FILE_PATH_LITERAL("t");
@@ -291,6 +299,7 @@ PlatformFileError ObfuscatedFileUtil::CreateOrOpen(
&file_info, file_flags, file_handle);
if (created && base::PLATFORM_FILE_OK == error)
*created = true;
+ TouchDirectory(db, parent_id);
ericu 2011/11/30 19:16:04 You don't want to touch the parent if the creation
tzik 2011/12/01 16:28:46 Done.
return error;
}
if (file_flags & base::PLATFORM_FILE_CREATE)
@@ -352,6 +361,7 @@ PlatformFileError ObfuscatedFileUtil::EnsureFileExists(
context->src_type(), FilePath(), &file_info, 0, NULL);
if (created && base::PLATFORM_FILE_OK == error)
*created = true;
+ TouchDirectory(db, parent_id);
ericu 2011/11/30 19:16:04 Perhaps it would be better to put the call inside
tzik 2011/12/01 16:28:46 Done.
return error;
}
@@ -391,6 +401,7 @@ PlatformFileError ObfuscatedFileUtil::CreateDirectory(
}
if (!recursive && components.size() - index > 1)
return base::PLATFORM_FILE_ERROR_NOT_FOUND;
+ TouchDirectory(db, parent_id);
for (; index < components.size(); ++index) {
FileInfo file_info;
file_info.name = components[index];
@@ -694,9 +705,12 @@ PlatformFileError ObfuscatedFileUtil::CopyOrMoveFile(
dest_file_path.BaseName().value());
if (!AllocateQuotaForPath(context, 1, dest_file_info.name.size()))
return base::PLATFORM_FILE_ERROR_NO_SPACE;
- return CreateFile(context, context->dest_origin_url(),
+ PlatformFileError error = CreateFile(context, context->dest_origin_url(),
context->dest_type(), src_data_path, &dest_file_info, 0,
NULL);
+ if (error == base::PLATFORM_FILE_OK)
+ TouchDirectory(db, dest_parent_id);
+ return error;
}
} else { // It's a move.
if (overwrite) {
@@ -712,6 +726,7 @@ PlatformFileError ObfuscatedFileUtil::CopyOrMoveFile(
UpdatePathQuotaUsage(context, context->src_origin_url(),
context->src_type(), -1,
-static_cast<int64>(src_file_info.name.size()));
+ TouchDirectory(db, src_file_info.parent_id);
ericu 2011/11/30 19:16:04 You need to update the destination directory's mti
tzik 2011/12/01 16:28:46 Done.
return base::PLATFORM_FILE_OK;
} else {
FileId dest_parent_id;
@@ -724,10 +739,13 @@ PlatformFileError ObfuscatedFileUtil::CopyOrMoveFile(
static_cast<int64>(dest_file_path.BaseName().value().size())
- static_cast<int64>(src_file_info.name.size())))
return base::PLATFORM_FILE_ERROR_NO_SPACE;
+ FileId src_parent_id = src_file_info.parent_id;
src_file_info.parent_id = dest_parent_id;
src_file_info.name = dest_file_path.BaseName().value();
if (!db->UpdateFileInfo(src_file_id, src_file_info))
return base::PLATFORM_FILE_ERROR_FAILED;
+ TouchDirectory(db, src_parent_id);
+ TouchDirectory(db, dest_parent_id);
UpdatePathQuotaUsage(
context, context->src_origin_url(), context->src_type(), 0,
static_cast<int64>(dest_file_path.BaseName().value().size()) -
@@ -770,8 +788,10 @@ PlatformFileError ObfuscatedFileUtil::CopyInForeignFile(
dest_file_path.BaseName().value());
if (!AllocateQuotaForPath(context, 1, dest_file_info.name.size()))
return base::PLATFORM_FILE_ERROR_NO_SPACE;
- return CreateFile(context, context->dest_origin_url(),
+ PlatformFileError error = CreateFile(context, context->dest_origin_url(),
context->dest_type(), src_file_path, &dest_file_info, 0, NULL);
+ TouchDirectory(db, dest_parent_id);
+ return error;
}
return base::PLATFORM_FILE_ERROR_FAILED;
}
@@ -803,6 +823,7 @@ PlatformFileError ObfuscatedFileUtil::DeleteFile(
if (base::PLATFORM_FILE_OK !=
underlying_file_util()->DeleteFile(context, data_path))
LOG(WARNING) << "Leaked a backing file.";
+ TouchDirectory(db, file_info.parent_id);
return base::PLATFORM_FILE_OK;
}
@@ -826,6 +847,7 @@ PlatformFileError ObfuscatedFileUtil::DeleteSingleDirectory(
AllocateQuotaForPath(context, -1, -static_cast<int64>(file_info.name.size()));
UpdatePathQuotaUsage(context, context->src_origin_url(), context->src_type(),
-1, -static_cast<int64>(file_info.name.size()));
+ TouchDirectory(db, file_info.parent_id);
return base::PLATFORM_FILE_OK;
}
« no previous file with comments | « no previous file | webkit/fileapi/obfuscated_file_util_unittest.cc » ('j') | webkit/fileapi/obfuscated_file_util_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698