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

Give install warning on all OS other than Linux #28761

Closed
wants to merge 2 commits into from
Closed
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::runningOnLinux()) {
return (int) exec ('stat -c %Y '. escapeshellarg ($fullPath));
} else if (\OC_Util::runningOnBSD() || \OC_Util::runningOnMac()) {
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::runningOnLinux()) {
$result = $this->exec("stat -c %s $arg");
} else if (strpos($os, 'bsd') !== false || strpos($os, 'darwin') !== false) {
} else if (\OC_Util::runningOnBSD() || \OC_Util::runningOnMac()) {
$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::runningOnLinux()) {
if (\OC_Util::runningOnMac()) {
$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()
array($os, $this->defaults->getName())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[ ] please not array()

Copy link
Contributor Author

@phil-davis phil-davis Aug 22, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took the example from https://doc.owncloud.org/server/10.0/developer_manual/core/translation.html

$l->t('%s is available. Get <a href="%s">more information</a>', array($data['versionstring'], $data['web']));

I guess that example is not the current way it is liked to be done.

),
'hint' => $this->l10n->t('For the best results, please consider using a GNU/Linux server instead.')
];
Expand Down
20 changes: 19 additions & 1 deletion lib/private/legacy/util.php
Original file line number Diff line number Diff line change
Expand Up @@ -1252,13 +1252,31 @@ public static function obEnd() {
}
}

/**
* Checks whether the server is running on Linux
*
* @return bool true if running on Linux, false otherwise
*/
public static function runningOnLinux() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

generally speaking we should not put more code into legacy classes .... but I have no better location where to but this ...

return (strtolower(substr(PHP_OS, 0, 5)) === 'linux');
}

/**
* Checks whether the server is running on Mac OS X
*
* @return bool true if running on Mac OS X, false otherwise
*/
public static function runningOnMac() {
return (strtoupper(substr(PHP_OS, 0, 6)) === 'DARWIN');
return (strtolower(substr(PHP_OS, 0, 6)) === 'darwin');
}

/**
* Checks whether the server is running on BSD
*
* @return bool true if running on BSD, false otherwise
*/
public static function runningOnBSD() {
return (strpos(strtolower(PHP_OS), 'bsd') !== false);
}

/**
Expand Down