From f517b0deab2847f4c39152d079645e7ae26e8b07 Mon Sep 17 00:00:00 2001 From: Stepan Usatiuk Date: Sat, 15 Jul 2023 22:26:15 +0200 Subject: [PATCH] remove unused repo cache functions --- src/commands/srcs/CommandRun.cpp | 1 - src/repo/includes/FileRepository.h | 3 --- src/repo/includes/Repository.h | 13 +------------ src/repo/srcs/FileRepository.cpp | 19 ------------------- 4 files changed, 1 insertion(+), 35 deletions(-) diff --git a/src/commands/srcs/CommandRun.cpp b/src/commands/srcs/CommandRun.cpp index 7e927af..da0346d 100644 --- a/src/commands/srcs/CommandRun.cpp +++ b/src/commands/srcs/CommandRun.cpp @@ -95,7 +95,6 @@ void CommandRun::run(Context ctx) { File repoFile = Serialize::deserialize(ctx.repo->getObject(Object::ObjectType::File, relPath)); if (!changeDetector.check({repoFile, ctx.repo}, {p, from})) { addFile(repoFile.id); - ctx.repo->addToCache(repoFile); progress.print("Skipped: " + relPath, 1); runnerStats.filesSkipped++; return; diff --git a/src/repo/includes/FileRepository.h b/src/repo/includes/FileRepository.h index 7300180..9f31118 100644 --- a/src/repo/includes/FileRepository.h +++ b/src/repo/includes/FileRepository.h @@ -43,9 +43,6 @@ public: Object::idType getObjectId(Object::ObjectType type, const std::string &key) const override; std::vector> getObjects(Object::ObjectType type) const override; - bool clearCache(Object::ObjectType type) override; - bool addToCache(const Object &obj) override; - bool exists(Object::ObjectType type, const std::string &key) const override; Object::idType getId() override; diff --git a/src/repo/includes/Repository.h b/src/repo/includes/Repository.h index 6b0f0d1..a48f62c 100644 --- a/src/repo/includes/Repository.h +++ b/src/repo/includes/Repository.h @@ -85,18 +85,7 @@ public: /// \return True if exists, False otherwise /// \throws Exception on any error virtual bool exists(Object::ObjectType type, const std::string &key) const = 0; - - /// Erases all the cache entries of object type \p type - /// \param type Type of the objects - /// \return True - virtual bool clearCache(Object::ObjectType type) = 0; - - /// Adds the object to the cache, but doesn't change it on disk otherwise - /// \param obj Constant reference to the object - /// \return True - /// \throws Exception on any error, or if the object doesn't exist - virtual bool addToCache(const Object &obj) = 0; - + /// Returns the next available object id virtual Object::idType getId() = 0; diff --git a/src/repo/srcs/FileRepository.cpp b/src/repo/srcs/FileRepository.cpp index 02596b1..d5318a8 100644 --- a/src/repo/srcs/FileRepository.cpp +++ b/src/repo/srcs/FileRepository.cpp @@ -225,22 +225,3 @@ void FileRepository::OffsetEntry::serialize(std::vector &out) const { FileRepository::OffsetEntry::OffsetEntry(unsigned long long int fileId, unsigned long long int offset, unsigned long long int length) : fileId(fileId), offset(offset), length(length) {} - -bool FileRepository::clearCache(Object::ObjectType type) { - keyIndex[type] = {}; - return true; -} - -bool FileRepository::addToCache(const Object &obj) { - { - std::unique_lock lock(repoLock); - if (offsetIndex.count(obj.id) == 0) - throw Exception("Object with id " + std::to_string(obj.id) + " doesn't exist!"); - } - { - std::lock_guard lock(repoLock); - keyIndex[obj.type][obj.getKey()] = obj.id; - } - - return true; -}