Skip to content
Snippets Groups Projects
Commit 7d39cd6d authored by Alex Barth's avatar Alex Barth
Browse files

If file is not to be copied, check whether file already exists, as file_save()...

If file is not to be copied, check whether file already exists, as file_save() won't do that for us (compare file_copy() and file_save()).
parent 249a3f3d
No related branches found
No related tags found
No related merge requests found
......@@ -304,6 +304,15 @@ class FeedsEnclosure extends FeedsElement {
$file = file_copy($file, $destination);
}
else {
// If file is not to be copied, check whether file already exists,
// as file_save() won't do that for us (compare file_copy() and
// file_save())
$existing_files = file_load_multiple(array(), array('uri' => $file->uri));
if (count($existing_files)) {
$existing = reset($existing_files);
$file->fid = $existing->fid;
$file->filename = $existing->filename;
}
file_save($file);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment