diff --git a/filefield_paths.module b/filefield_paths.module
index 3c357b5..2439771 100644
--- a/filefield_paths.module
+++ b/filefield_paths.module
@@ -127,8 +127,7 @@ function filefield_paths_form_alter(&$form, $form_state, $form_id) {
$form['instance']['settings']['filefield_paths']['replace_existing_files'] = array(
'#type' => 'checkbox',
'#title' => t('Replace existing files'),
- '#description' => t('If a file with the same name already exists in the destination directory, replace it') . '.' .
- '
' . t('To use this feature, you must change the "File name" option to be something other than the exact name of the uploaded file') . '.',
+ '#description' => t('If a file with the same name already exists in the destination directory, replace it.'),
'#weight' => 11,
'#default_value' => isset($settings['replace_existing_files']) ? $settings['replace_existing_files'] : FALSE,
'#disabled' => FALSE //isset($settings['file_name']) && $settings['file_name']['value'] == '[file:ffp-name-only-original].[file:ffp-extension-original]' ? TRUE : FALSE
@@ -139,7 +138,7 @@ function filefield_paths_form_alter(&$form, $form_state, $form_id) {
'#type' => 'checkbox',
'#title' => t('Retroactive update'),
'#description' => t('Move and rename previously uploaded files.') . '
' . t('Warning: This feature should only be used on developmental servers or with extreme caution.') . '
',
- '#weight' => 11,
+ '#weight' => 12,
);
// Active updating.
@@ -148,7 +147,7 @@ function filefield_paths_form_alter(&$form, $form_state, $form_id) {
'#title' => t('Active updating'),
'#default_value' => isset($settings['active_updating']) ? $settings['active_updating'] : FALSE,
'#description' => t('Actively move and rename previously uploaded files as required.') . '' . t('Warning: This feature should only be used on developmental servers or with extreme caution.') . '
',
- '#weight' => 12
+ '#weight' => 13
);
}
}
diff --git a/modules/filefield_paths.inc b/modules/filefield_paths.inc
index a4dfdbb..94aa5ca 100644
--- a/modules/filefield_paths.inc
+++ b/modules/filefield_paths.inc
@@ -65,14 +65,19 @@ function filefield_paths_filefield_paths_process_file($type, $entity, $field, $i
$file['uri'] = "{$field['settings']['uri_scheme']}://" . ltrim(filefield_paths_process_string($settings['file_path']['value'], $token_data, $settings['file_path']['options']) . "/{$file['filename']}", '/');
// Finalize file if necessary.
- if ($file !== $old_file) {
+ if ($file['uri'] !== $old_file['uri']) {
$dirname = drupal_dirname($file['uri']);
$file_exists_behavior = empty($settings['replace_existing_files'])? FILE_EXISTS_RENAME : FILE_EXISTS_REPLACE;
+ $file_exists_behavior = empty($settings['replace_existing_files']) ? FILE_EXISTS_RENAME : FILE_EXISTS_REPLACE;
if (file_prepare_directory($dirname, FILE_CREATE_DIRECTORY)) {
$old_file['filename'] = $file['filename'];
$moved_file = file_move((object) $old_file, $file['uri'], $file_exists_behavior);
if ($moved_file && $moved_file->fid != $file['fid']) {
+ $entity->{$instance['field_name']}[$entity->language][0] = (array) $moved_file;
+ file_delete((object) $old_file, TRUE);
+ }
+
$entity->{$instance['field_name']}[$entity->language][0] = (array)$moved_file;
file_delete((object)$old_file, TRUE);
}