diff options
-rw-r--r-- | netfs/fuse/fuseApp.cpp | 4 | ||||
-rw-r--r-- | netfs/fuse/fuseApp.h | 2 | ||||
-rw-r--r-- | netfs/fuse/fuseDirs.cpp | 4 | ||||
-rw-r--r-- | netfs/fuse/fuseFiles.cpp | 2 | ||||
-rw-r--r-- | netfs/unittests/testFuse.cpp | 6 |
5 files changed, 10 insertions, 8 deletions
diff --git a/netfs/fuse/fuseApp.cpp b/netfs/fuse/fuseApp.cpp index f21c8c3..0018b20 100644 --- a/netfs/fuse/fuseApp.cpp +++ b/netfs/fuse/fuseApp.cpp @@ -16,8 +16,8 @@ #include <uriParse.h> namespace AdHoc { - template class Cache<struct stat, std::string>; - template class CallCacheable<struct stat, std::string>; + template class Cache<struct stat, std::size_t>; + template class CallCacheable<struct stat, std::size_t>; } NetFS::FuseApp::FuseApp(Ice::StringSeq && a) : iceArgs(std::move(a)) { } diff --git a/netfs/fuse/fuseApp.h b/netfs/fuse/fuseApp.h index 790f88a..b2166df 100644 --- a/netfs/fuse/fuseApp.h +++ b/netfs/fuse/fuseApp.h @@ -120,7 +120,7 @@ namespace NetFS { EntryTypeConverter converter; - using StatCache = AdHoc::Cache<struct stat, std::string>; + using StatCache = AdHoc::Cache<struct stat, std::size_t>; StatCache statCache; }; } diff --git a/netfs/fuse/fuseDirs.cpp b/netfs/fuse/fuseDirs.cpp index dd5f0db..3ea7c0d 100644 --- a/netfs/fuse/fuseDirs.cpp +++ b/netfs/fuse/fuseDirs.cpp @@ -47,13 +47,13 @@ namespace NetFS { { try { auto od = getProxy<OpenDirPtr>(fi->fh); - const std::string path(p); + const std::filesystem::path path {p}; auto expiry = time(nullptr) + 2; if (flags & FUSE_READDIR_PLUS) { for (const auto & e : od->remote->listdir()) { if (auto stat = converter.convert(e.second); stat.st_mode) { filler(buf, e.first.c_str(), nullptr, 0, FUSE_FILL_DIR_PLUS); - const std::string k(path + e.first); + const auto k {std::filesystem::hash_value(path / e.first)}; statCache.remove(k); statCache.add(k, stat, expiry); } diff --git a/netfs/fuse/fuseFiles.cpp b/netfs/fuse/fuseFiles.cpp index 29a0096..149e8b3 100644 --- a/netfs/fuse/fuseFiles.cpp +++ b/netfs/fuse/fuseFiles.cpp @@ -376,7 +376,7 @@ namespace NetFS { *s = converter.convert(remote->fgetattr()); } else { - if (auto cacehedStat = statCache.get(p)) { + if (auto cacehedStat = statCache.get(std::filesystem::hash_value(p))) { *s = *cacehedStat; } else { diff --git a/netfs/unittests/testFuse.cpp b/netfs/unittests/testFuse.cpp index ae99b55..c04c52c 100644 --- a/netfs/unittests/testFuse.cpp +++ b/netfs/unittests/testFuse.cpp @@ -47,6 +47,8 @@ BOOST_AUTO_TEST_CASE(fuse, *boost::unit_test::timeout(5)) BOOST_AUTO_TEST_CASE(fuse_ls, *boost::unit_test::timeout(5)) { + static const auto ME_HASH {std::filesystem::hash_value("/me")}; + BOOST_REQUIRE(std::filesystem::is_directory(mntpnt)); BOOST_REQUIRE(std::filesystem::is_empty(mntpnt)); const auto rpath = mntpnt / "me"; @@ -57,13 +59,13 @@ BOOST_AUTO_TEST_CASE(fuse_ls, *boost::unit_test::timeout(5)) const auto st_local = get_lstat(lpath); - BOOST_CHECK(!fuseApp.getStatCache().get("/me")); + BOOST_CHECK(!fuseApp.getStatCache().get(ME_HASH)); std::set<std::filesystem::path> paths(std::filesystem::directory_iterator(mntpnt), {}); BOOST_REQUIRE_EQUAL(paths.size(), 1); BOOST_CHECK_EQUAL(paths.begin()->filename(), "me"); - auto cached = fuseApp.getStatCache().get("/me"); + auto cached = fuseApp.getStatCache().get(ME_HASH); BOOST_REQUIRE(cached); const auto & st_cache = (*cached); BOOST_CHECK_EQUAL_STAT(st_cache, st_local); |