From 561ca215932fabb051f6acb4df40432d193e98b3 Mon Sep 17 00:00:00 2001 From: Takeshi Nakatani Date: Tue, 7 Nov 2023 11:55:39 +0000 Subject: [PATCH] Improved updating of temporary stat cache while creating a file --- src/s3fs.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/s3fs.cpp b/src/s3fs.cpp index 4fe6fdc24f..d544169b10 100644 --- a/src/s3fs.cpp +++ b/src/s3fs.cpp @@ -2563,6 +2563,21 @@ static int s3fs_utimens(const char* _path, const struct timespec ts[2]) // If there is data in the Stats cache, update the Stats cache. StatCache::getStatCacheData()->UpdateMetaStats(strpath, updatemeta); + // [NOTE] + // There are cases where this function is called during the process of + // creating a new file (before uploading). + // In this case, a temporary cache exists in the Stat cache.(see s3fs_create) + // So we need to update the cache, if it exists. + // + // Previously, the process of creating a new file was to update the + // file content after first uploading the file, but now the file is + // not created until flushing. + // So we need to create a temporary Stat cache for it. + // + if(!StatCache::getStatCacheData()->AddStat(strpath, updatemeta, false, true)){ + return -EIO; + } + }else{ S3FS_PRN_INFO("meta is not pending, but need to keep current mtime.");