diff --git a/uuid.core.inc b/uuid.core.inc index f893ff1..13a889c 100644 --- a/uuid.core.inc +++ b/uuid.core.inc @@ -126,7 +126,16 @@ function file_entity_uuid_presave(&$entity, $entity_type) { if ($entity_type == 'file') { entity_property_uuid_to_id($entity, 'user', 'uid'); + // Write the new file to the local filesystem. if (isset($entity->file_contents)) { + // Don't try to write it if it uses a stream wrapper that isn't writeable + // (for example, if it is a remotely-hosted video). + $scheme = file_uri_scheme($entity->uri); + $wrappers = file_get_stream_wrappers(STREAM_WRAPPERS_WRITE); + if (empty($wrappers[$scheme])) { + return; + } + // Check for an existing file with the same URI. $existing_files = file_load_multiple(array(), array('uri' => $entity->uri)); $existing = (object) array('uri' => NULL, 'uuid' => NULL);