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

Unified Diff: mount.cc

Issue 6598074: DoAutomaticFreeDiskSpaceControl() introduced (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/cryptohome.git@master
Patch Set: Created 9 years, 10 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
« no previous file with comments | « mount.h ('k') | mount_task.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mount.cc
diff --git a/mount.cc b/mount.cc
index 9f69d2593ed17b938b3a865585c7733afe39766e..b39bac895e68a6d14d011fdb37888245a4952064 100644
--- a/mount.cc
+++ b/mount.cc
@@ -478,7 +478,7 @@ bool Mount::CreateTrackedSubdirectories(const Credentials& credentials,
return result;
}
-void Mount::CleanUnmountedTrackedSubdirectories() const {
+void Mount::DoForEveryUnmountedCryptohome(CryptohomeCallback callback) const {
FilePath shadow_root(shadow_root_);
file_util::FileEnumerator dir_enumerator(shadow_root, false,
file_util::FileEnumerator::DIRECTORIES);
@@ -507,25 +507,48 @@ void Mount::CleanUnmountedTrackedSubdirectories() const {
if (platform_->IsDirectoryMountedWith(home_dir_, vault_path.value())) {
continue;
}
- file_util::FileEnumerator subdir_enumerator(
- vault_path,
- false,
- file_util::FileEnumerator::DIRECTORIES);
- for (FilePath subdir_path = subdir_enumerator.Next(); !subdir_path.empty();
- subdir_path = subdir_enumerator.Next()) {
- FilePath subdir_name = subdir_path.BaseName();
- if (subdir_name.value().find(kEncryptedFilePrefix) == 0) {
- continue;
- }
- if (subdir_name.value().compare(".") == 0 ||
- subdir_name.value().compare("..") == 0) {
- continue;
- }
- file_util::Delete(subdir_path, true);
+ callback(vault_path);
+ }
+}
+
+// Deletes all tracking subdirectories of the given vault.
+static void DeleteTrackedDirsCallback(const FilePath& vault) {
+ file_util::FileEnumerator subdir_enumerator(
+ vault, false, file_util::FileEnumerator::DIRECTORIES);
+ for (FilePath subdir_path = subdir_enumerator.Next(); !subdir_path.empty();
+ subdir_path = subdir_enumerator.Next()) {
+ FilePath subdir_name = subdir_path.BaseName();
+ if (subdir_name.value().find(kEncryptedFilePrefix) == 0) {
+ continue;
+ }
+ if (subdir_name.value().compare(".") == 0 ||
+ subdir_name.value().compare("..") == 0) {
+ continue;
}
+ file_util::Delete(subdir_path, true);
}
}
+void Mount::CleanUnmountedTrackedSubdirectories() const {
+ DoForEveryUnmountedCryptohome(&DeleteTrackedDirsCallback);
+}
+
+// Deletes Cache tracking directory of the given vault.
+static void DeleteCacheCallback(const FilePath& vault) {
+ LOG(WARNING) << "Deleting Cache for user " << vault.value();
+ file_util::Delete(vault.Append(kCacheDir), true);
+}
+
+void Mount::DoAutomaticFreeDiskSpaceControl() const {
+ if (platform_->AmountOfFreeDiskSpace(home_dir_) > kMinFreeSpace)
+ return;
+
+ // Clean Cache directories for every user (except current one).
+ DoForEveryUnmountedCryptohome(&DeleteCacheCallback);
+
+ // TODO(glotov): do further cleanup.
+}
+
bool Mount::TestCredentials(const Credentials& credentials) const {
// If the current logged in user matches, use the UserSession to verify the
// credentials. This is less costly than a trip to the TPM, and only verifies
« no previous file with comments | « mount.h ('k') | mount_task.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698