[Scummvm-git-logs] scummvm-web master -> 2d73bc74cc086b455aafdcfd483de7fb0d53373c
lotharsm
noreply at scummvm.org
Sun Jan 9 23:55:06 UTC 2022
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm-web' repo located at https://github.com/scummvm/scummvm-web .
Summary:
2d73bc74cc WEB: Use absolute file path if available
Commit: 2d73bc74cc086b455aafdcfd483de7fb0d53373c
https://github.com/scummvm/scummvm-web/commit/2d73bc74cc086b455aafdcfd483de7fb0d53373c
Author: Thunderforge (wjherrmann at gmail.com)
Date: 2022-01-10T00:55:03+01:00
Commit Message:
WEB: Use absolute file path if available
I suspect this will fix an issue with the hashes and such showing up locally, but not on the server.
Changed paths:
include/Constants.php
include/Objects/File.php
diff --git a/include/Constants.php b/include/Constants.php
index 9e27a5ae..f99df256 100644
--- a/include/Constants.php
+++ b/include/Constants.php
@@ -40,7 +40,8 @@ class Constants
define('DIR_DATA', DIR_BASE . '/data');
define('DIR_DOWNLOADS', '/downloads');
define('DIR_SCREENSHOTS', '/data/screenshots');
- define('DIR_FRS', '/.0/frs');
+ define('DIR_SERVER_ROOT', '/.0');
+ define('DIR_FRS', DIR_SERVER_ROOT . '/frs');
/* Locale */
define('DEFAULT_LOCALE', 'en');
diff --git a/include/Objects/File.php b/include/Objects/File.php
index 167747e4..8b19e86d 100644
--- a/include/Objects/File.php
+++ b/include/Objects/File.php
@@ -44,10 +44,11 @@ class File extends BasicObject
}
$fname = str_replace('{$version}', "$this->version", $fname);
- // If the file is on this server, we can check file size etc.
- if (is_file($fname) && is_readable($fname)) {
- $this->extra_info = array();
- $sz = round((@filesize($fname) / 1024));
+ // Use an absolute file path if available, otherwise use the relative path
+ $path = is_file(DIR_SERVER_ROOT . '/'. $fname) ? DIR_SERVER_ROOT . '/'. $fname : $fname;
+ if (is_file($path) && is_readable($path)) {
+ // Calculate the file size, etc.
+ $sz = round((@filesize($path) / 1024));
if ($sz < 1024) {
$sz = $sz . "K";
@@ -68,18 +69,18 @@ class File extends BasicObject
$ext = substr($url, strrpos($url, '.', -(strlen($url) - strrpos($url, '.') + 1)));
}
- if ((is_file($fname . '.sha256') && is_readable($fname . '.sha256'))
- && (@filemtime($fname . '.sha256') > @filemtime($fname))
+ if ((is_file($path . '.sha256') && is_readable($path . '.sha256'))
+ && (@filemtime($path . '.sha256') > @filemtime($path))
) {
- $this->extra_info['sha256'] = file_get_contents($fname . '.sha256');
+ $this->extra_info['sha256'] = file_get_contents($path . '.sha256');
} else {
- $hash = hash_file('sha256', $fname);
+ $hash = hash_file('sha256', $path);
$this->extra_info['sha256'] = $hash;
- file_put_contents($fname . '.sha256', $hash);
+ file_put_contents($path . '.sha256', $hash);
}
$this->extra_info['ext'] = $ext;
- $this->extra_info['date'] = date('F j, Y, g:i a', @filemtime($fname));
+ $this->extra_info['date'] = date('F j, Y, g:i a', @filemtime($path));
$this->extra_info['msg'] = isset($data['notes']) ? $data['notes'] : '';
}
$this->url = $fname;
More information about the Scummvm-git-logs
mailing list