We should not query any mirrors for files that even we don't have
ourselves.
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
)
@run_in_thread
- def exists(self, *args, **kwargs):
+ def exists(self, path):
"""
Checks whether a file exists
"""
- return os.path.exists(*args, **kwargs)
+ # Make the path absolute
+ if not path.startswith("/"):
+ path = self.path(path)
+
+ return os.path.exists(path)
@run_in_thread
def makedirs(self, path, **kwargs):
"""
@base.ratelimit(limit=100, minutes=60, key="downloads")
async def get(self, path):
+ # Check if the file exists
+ if not await self.backend.exists(path):
+ raise tornado.web.HTTPError(404)
+
# Fetch all mirrors for this client
mirrors = await self.backend.mirrors.get_mirrors_for_address(self.current_address)