Add check that the file permissions really were changed after we tried to change them.
This commit is contained in:
parent
f72597ba78
commit
6d4cdbd007
1 changed files with 21 additions and 6 deletions
|
@ -126,21 +126,36 @@ function camp_import_audio_file($p_filepath, $p_importMode = null, $p_testOnly =
|
||||||
|
|
||||||
// Set the file permissions to be world-readable
|
// Set the file permissions to be world-readable
|
||||||
if ($p_importMode == "link") {
|
if ($p_importMode == "link") {
|
||||||
|
// Check current file permissions
|
||||||
$fileperms = fileperms($p_filepath);
|
$fileperms = fileperms($p_filepath);
|
||||||
$worldReadable = ($fileperms & 0x0004);
|
$worldReadable = ($fileperms & 0x0004);
|
||||||
|
|
||||||
if (!$worldReadable) {
|
if (!$worldReadable) {
|
||||||
|
$permError = false;
|
||||||
|
// Check if we have the ability to change the perms
|
||||||
if (is_writable($p_filepath)) {
|
if (is_writable($p_filepath)) {
|
||||||
|
// Change the file perms
|
||||||
$fileperms = $fileperms | 0x0004;
|
$fileperms = $fileperms | 0x0004;
|
||||||
chmod($p_filepath, $fileperms);
|
chmod($p_filepath, $fileperms);
|
||||||
|
|
||||||
|
// Check that file perms were changed
|
||||||
|
clearstatcache();
|
||||||
|
$fileperms = fileperms($p_filepath);
|
||||||
|
$worldReadable = ($fileperms & 0x0004);
|
||||||
|
if (!$worldReadable) {
|
||||||
|
$permError = true;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
|
$permError = true;
|
||||||
|
}
|
||||||
|
if ($permError) {
|
||||||
global $g_errors;
|
global $g_errors;
|
||||||
$g_errors++;
|
$g_errors++;
|
||||||
echo
|
echo "ERROR: $p_filepath\n"
|
||||||
"ERROR: $p_filepath
|
." When importing with the '--link' option, files must be set\n"
|
||||||
When importing with the '--link' option, files must be set
|
." world-readable. The file permissions for the file cannot be\n"
|
||||||
world-readable. The file permissions for the following file
|
." changed. Check that you are not trying to import from a FAT32\n"
|
||||||
cannot be changed. We suggest running this script with 'sudo'.\n";
|
." drive. Otherwise, this problem might be fixed by running this \n"
|
||||||
|
." script with 'sudo'.\n";
|
||||||
return array($fileCount, $duplicates);
|
return array($fileCount, $duplicates);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue