Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable10] Handle BSD case for 32 bit filemtime and install warning #28790

Merged
merged 2 commits into from
Aug 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/private/Files/Storage/Local.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,12 @@ public function filemtime($path) {
return false;
}
if (PHP_INT_SIZE === 4) {
return (int) exec ('stat -c %Y '. escapeshellarg ($fullPath));
if (\OC_Util::runningOn('linux')) {
return (int) exec ('stat -c %Y '. escapeshellarg ($fullPath));
} else if (\OC_Util::runningOn('bsd') || \OC_Util::runningOn('mac')) {
return (int) exec ('stat -f %m '. escapeshellarg ($fullPath));
}
return false;
}
return filemtime($fullPath);
}
Expand Down
11 changes: 2 additions & 9 deletions lib/private/LargeFileHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,19 +142,12 @@ public function getFileSizeViaCurl($fileName) {
*/
public function getFileSizeViaExec($filename) {
if (\OC_Helper::is_function_enabled('exec')) {
$os = strtolower(php_uname('s'));
$arg = escapeshellarg($filename);
$result = null;
if (strpos($os, 'linux') !== false) {
if (\OC_Util::runningOn('linux')) {
$result = $this->exec("stat -c %s $arg");
} else if (strpos($os, 'bsd') !== false || strpos($os, 'darwin') !== false) {
} else if (\OC_Util::runningOn('bsd') || \OC_Util::runningOn('mac')) {
$result = $this->exec("stat -f %z $arg");
} else if (strpos($os, 'win') !== false) {
$result = $this->exec("for %F in ($arg) do @echo %~zF");
if (is_null($result)) {
// PowerShell
$result = $this->exec("(Get-Item $arg).length");
}
}
return $result;
}
Expand Down
12 changes: 9 additions & 3 deletions lib/private/Setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,18 @@ public function getSystemInfo($allowAllDatabases = false) {
\OC\Setup::protectDataDirectory();
}

if (\OC_Util::runningOnMac()) {
if (!\OC_Util::runningOn('linux')) {
if (\OC_Util::runningOn('mac')) {
$os = 'Mac OS X';
} else {
$os = PHP_OS;
}

$errors[] = [
'error' => $this->l10n->t(
'Mac OS X is not supported and %s will not work properly on this platform. ' .
'%s is not supported and %s will not work properly on this platform. ' .
'Use it at your own risk! ',
$this->defaults->getName()
[$os, $this->defaults->getName()]
),
'hint' => $this->l10n->t('For the best results, please consider using a GNU/Linux server instead.')
];
Expand Down
15 changes: 11 additions & 4 deletions lib/private/legacy/util.php
Original file line number Diff line number Diff line change
Expand Up @@ -1250,12 +1250,19 @@ public static function obEnd() {
}

/**
* Checks whether the server is running on Mac OS X
* Checks whether the server is running on the given OS type
*
* @return bool true if running on Mac OS X, false otherwise
* @param string $osType linux|mac|bsd etc
* @return bool true if running on that OS type, false otherwise
*/
public static function runningOnMac() {
return (strtoupper(substr(PHP_OS, 0, 6)) === 'DARWIN');
public static function runningOn($osType) {
$osType = strtolower($osType) === 'mac' ? 'darwin' : strtolower($osType);

if ($osType === 'bsd') {
return (strpos(strtolower(PHP_OS), $osType) !== false);
} else {
return (strtolower(substr(PHP_OS, 0, strlen($osType))) === $osType);
}
}

/**
Expand Down