#!/usr/bin/python
+import os
import re
import base
@property
def is_in_cache(self):
+ # Local files are always kinda cached.
+ if self.repo.local:
+ return True
+
return self.repo.cache.exists("package/%s" % self.filename)
def get_from_cache(self):
- filename = "packages/%s" % self.filename
+ path = None
+
+ if self.repo.local:
+ path = os.path.join(self.repo.path, self.arch, self.filename)
+ return binary.BinaryPackage(self.pakfire, self.repo, path)
+ else:
+ filename = "packages/%s" % self.filename
+
+ if self.repo.cache.exists(filename):
+ path = self.repo.cache.abspath(filename)
- if self.repo.cache.exists(filename):
- return binary.BinaryPackage(self.pakfire, self.repo, self.repo.cache.abspath(filename))
+ if path:
+ return binary.BinaryPackage(self.pakfire, self.repo, path)
def download(self, text=""):
- self.repo.download(self.filename, text=text, hash1=self.hash1)
+ if not self.repo.local:
+ self.repo.download(self, text=text)
return self.get_from_cache()
return priority
- def download(self, filename, hash1=None, text=""):
+ def download(self, pkg, text=""):
"""
Downloads 'filename' from repository and returns the local filename.
"""
+ filename, hash1 = pkg.filename, pkg.hash1
+
# Marker, if we need to download the package.
download = True