From: Michael Tremer Date: Sat, 20 Jan 2018 13:11:50 +0000 (+0100) Subject: Drop python implementation of repository cache X-Git-Tag: 0.9.28~1285^2~1149 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f1820b13b8bd234e11e50ae21bcadd7e9aac01de;p=pakfire.git Drop python implementation of repository cache Signed-off-by: Michael Tremer --- diff --git a/Makefile.am b/Makefile.am index 1b7af8691..9e2ff901d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -157,7 +157,6 @@ pakfire_packagesdir = $(pythondir)/pakfire/packages pakfire_repository_PYTHON = \ src/pakfire/repository/__init__.py \ src/pakfire/repository/base.py \ - src/pakfire/repository/cache.py \ src/pakfire/repository/database.py \ src/pakfire/repository/local.py \ src/pakfire/repository/metadata.py \ diff --git a/src/pakfire/repository/cache.py b/src/pakfire/repository/cache.py deleted file mode 100644 index 23641fe65..000000000 --- a/src/pakfire/repository/cache.py +++ /dev/null @@ -1,129 +0,0 @@ -#!/usr/bin/python -############################################################################### -# # -# Pakfire - The IPFire package management system # -# Copyright (C) 2011 Pakfire development team # -# # -# This program is free software: you can redistribute it and/or modify # -# it under the terms of the GNU General Public License as published by # -# the Free Software Foundation, either version 3 of the License, or # -# (at your option) any later version. # -# # -# This program is distributed in the hope that it will be useful, # -# but WITHOUT ANY WARRANTY; without even the implied warranty of # -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # -# GNU General Public License for more details. # -# # -# You should have received a copy of the GNU General Public License # -# along with this program. If not, see . # -# # -############################################################################### - -import os -import stat -import time - -import pakfire.util as util -from pakfire.constants import * - -class RepositoryCache(object): - """ - An object that is able to cache all data that is loaded from a - remote repository. - """ - path = REPO_CACHE_DIR - - def __init__(self, pakfire, repo): - self.pakfire = pakfire - self.repo = repo - - self.__created = None - - @property - def created(self): - """ - Tells us, if the cache was already created. - """ - if self.__created is None: - self.__created = os.path.exists(self.path) - - return self.__created - - def abspath(self, path, create=True): - if create: - self.create() - - return os.path.join(self.path, path) - - def create(self): - """ - Create all necessary directories. - """ - # Do nothing, if the cache has already been created. - if self.created: - return - - if not os.path.exists(self.path): - os.makedirs(self.path) - - self.__created = True - - def exists(self, filename): - """ - Returns True if a file exists and False if it doesn't. - """ - return os.path.exists(self.abspath(filename)) - - def age(self, filename): - """ - Returns the age of a downloaded file in minutes. - i.e. the time from download until now. - """ - if not self.exists(filename): - return None - - filename = self.abspath(filename) - - # Creation time of the file - ctime = os.stat(filename)[stat.ST_CTIME] - - return (time.time() - ctime) / 60 - - def open(self, filename, *args, **kwargs): - filename = self.abspath(filename) - - # Create directory if not existant. - dirname = os.path.dirname(filename) - if not os.path.exists(dirname): - os.makedirs(dirname) - - return open(filename, *args, **kwargs) - - def hash1(self, filename): - """ - Return hash of the file in the cache. - """ - return util.calc_hash1(self.abspath(filename)) - - def verify(self, filename, hash1): - """ - Return a bool that indicates if a file matches the given hash. - """ - return self.hash1(filename) == hash1 - - def remove(self, filename): - """ - Remove a file from cache. - """ - if not self.exists(filename): - return - - filename = self.abspath(filename) - os.unlink(filename) - - def destroy(self): - """ - Remove all files from this cache. - """ - if self.created: - util.rm(self.path) diff --git a/src/pakfire/repository/remote.py b/src/pakfire/repository/remote.py index 4ad4b221a..6d64253a8 100644 --- a/src/pakfire/repository/remote.py +++ b/src/pakfire/repository/remote.py @@ -30,7 +30,6 @@ from .. import http from .. import util from . import base -from . import cache from . import metadata from ..constants import *