File is deleted when try to remove and add the file with same name on node edit page

Murz - September 28, 2009 - 11:53
Project:Upload File Replace (for filefield CCK)
Version:6.x-1.0
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed
Description

When I try to replace the file with newer version of it (with same name), the file in filefield have wrong filename and dead link.

How to reproduce:
1. Upload a file to a filefield (for example, "test2.txt")
2. Save the node
3. Go to edit form
4. Press "Remove" in filefield
5. Upload file "test2.txt" again
6. Press Save.

After that in folder I see file "test2_0.txt" and "test2.txt" is deleted, but in node I see the link to file "test2.txt" that isn't exists.

If I press "Save" and after that - "Edit" between 4 and 5 steps, all works good.

#1

markDrupal - October 6, 2009 - 18:46

I'm not able to reproduce this error. This is the basic functionality of the module and it works when I tried it.

You should check your temp file directory "admin/settings/file-system" and see if the file gets moved there. It is possible that the file gets moved to the temp directory but you don't have permissions to write or read the temp directory. Again, it should fail with an error, so I'm not sure what is happening for you.

#2

markDrupal - October 15, 2009 - 21:04
Status:active» postponed (maintainer needs more info)

#3

Murz - October 29, 2009 - 13:00
Version:6.x-1.0-rc5» 6.x-1.0

It is reproducible for me on latest version with fresh site with installed modules:
Drupal core modules 6.14
CCK 6.x-2.5
Upload replace 6.x-1.0
All other modules is off.

Algoritm to reproduce:
1. Create new node with filefield field (number of files - 1).
2. Upload file "test4.txt" to filefield.
3. Save the node.
You see the correct link to the file: files/test2/test4.txt
5. Press "Edit" on this node.
6. Press "Remove" button on filefield.
7. Press "Browse" button and select "test4.txt".
8. Press "Upload". In widget you will see the link: files/test2/test4_0.txt
This link is works normally.
9. Press "Save" button for node.
10. Look at the link in filefield - it becomes: files/test2/test4.txt but this link is broken, file is still files/test2/test4_0.txt in filesystem!

#4

Murz - October 29, 2009 - 13:03
Status:postponed (maintainer needs more info)» active

#5

markDrupal - October 29, 2009 - 19:24
Status:active» fixed

Thanks, I found the problem with sites with revisioning disabled.
Adding a hook_file_delete allowed me to update the file path before the delete occurs.
Anyways I was able to fix this issue and committed to 1.1

#6

System Message - November 12, 2009 - 19:30
Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.