When trying to setup automated resets, kept receiving an error "The snapshot directory demo could not be created."
Did some digging and the offender was the call to file_prepare_directory in demo_admin_settings_validate [demo.admin.inc]. As the "private://" stream identifier was not passed, the file_prepare_directory function would fail as there would be no directory to find. Adding in the stream identifier so there was a full URI to parse fixed the issue.
Before Fix
function demo_admin_settings_validate($form, &$form_state) {
if (!file_prepare_directory($form_state['values']['demo_dump_path'], FILE_CREATE_DIRECTORY)) {
form_set_error('demo_dump_path', t('The snapshot directory %directory could not be created.', array('%directory' => $form_state['values']['demo_dump_path'])));
}
}
After Fix
function demo_admin_settings_validate($form, &$form_state) {
$fullpath = 'private://'.$form_state['values']['demo_dump_path'];
$dirprep = file_prepare_directory($fullpath, FILE_CREATE_DIRECTORY);
if (!$dirprep) {
form_set_error('demo_dump_path', t('The snapshot directory %directory could not be created.', array('%directory' => $form_state['values']['demo_dump_path'])));
}
}
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | addprivateprefix-1153206-2.patch | 859 bytes | zeip |
Comments
Comment #1
BarisW commentedI can confirm this. It only goes wrong when the default file system settings are set to public. I changed the code to this:
Comment #2
zeip commentedI had the same problem, the change in #1 worked. Attached is a patch to fix this.
Comment #3
davidtrainer commentedI can confirm this patch works.
Comment #4
izmeez commentedI can also confirm this patch applies to 7.x-1.x-dev and works. It resolves #2072229: Demo settings should return ok message if path already exists that i shall close as a duplicate of this issue.
Thanks.
Comment #5
cecrs commentedAlso can confirm the patch works.
Comment #6
gaurav.kapoor commentedLil documentation would improve the patch. Will add that while commit.
Comment #7
gaurav.kapoor commentedComment #8
gaurav.kapoor commented