return ret
+ def get_file(self, filename):
+ res = self.db.get("SELECT * FROM filelists \
+ WHERE pkg_id = %s AND name = %s", self.id, filename)
+
+ if res:
+ return File(self.backend, res)
+
def add_file(self, name, size, hash_sha512, type, config, mode, user, group, mtime, capabilities):
# Convert mtime from seconds since epoch to datetime
mtime = datetime.datetime.utcfromtimestamp(float(mtime))
\"user\", \"group\", mtime, capabilities) VALUES(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
self.id, name, size, hash_sha512, type, config, mode, user, group, mtime, capabilities)
- def get_file(self):
+ def open(self):
path = os.path.join(PACKAGES_DIR, self.path)
if os.path.exists(path):
raise tornado.web.HTTPError(404, "Package not found: %s" % pkg_uuid)
# Check if the package has got a file with the given name.
- if not filename in [f.name for f in pkg.filelist]:
+ file = pkg.get_file(filename)
+ if not file:
raise tornado.web.HTTPError(404, "Package %s does not contain file %s" % (pkg, filename))
# Open the package in the filesystem.
- pkg_file = pkg.get_file()
+ pkg_file = pkg.open()
if not pkg_file:
raise tornado.web.HTTPError(404, "Could not open package %s" % pkg.path)