I am trying to do a batch delete on files via task. Check if the files are delete on the db (using orm/soft). I am used to deleting files normally in non-task way and it works fine. But in task, it is giving me this error.
Error - Cannot delete file: given path "/path/to/file/in/the/app/share/93fa7fe9ab4b7098d1f809636e64d6b6.jpg" is not a file. in COREPATH/classes/file.php on line 578
I tried it on windows via xampp same error. I figured that it would work in linux OSes because of the difference between / and \.
Here is my code.
protected static function _delete_file($path)
{
if(file_exists($path))
{
print $path;
print \Fuel\Core\File::delete($path);
}
}
Also file_exist is not seeing it as a file either. So I removed it to show the error.
Which means that the possible culprit is DOCROOT. Which means you have to check your index.php to make sure it uses Windows paths instead of Linux paths.
But I also uploaded it on lunix to test that case, it still doesn't delete the file. Also when I use the delete inside the app (Model and Controller) it is working just fine.
Then it might be a rights issue. When it's uploaded and written in the app, it will have the rights of your webserver user. Those may be differrent from your commandline user that runs the tasks.
Yes, correct, in both cases. To create an environment that gives both access, you need to do some planning.
On our servers, we have a group www-data, both apache and all user accounts used on the commandline are member of this group. This group is assigned to all files and directories, with the sticky bit on (so new files will automatically inherit this group). Directories are created with a 770 mask, files with a 660 mask.
This gives everyone in the group read/write access on all files, no matter who created them (i.e. who the owner of the file is).