OK, I've been trying several different alternatives, combination of modules, tweaks to existing modules, but now I'm LOST.
The core upload module has many deficiencies that are well documented (flat file system, etc.). We've installed the following modules that seem to mitigate many of our core issues.
http://drupal.org/project/filefield_paths
http://drupal.org/project/file_aliases
NOTE: We also have http://drupal.org/project/filefield installed and both the above modules seem to work well together.
Now to the issue at hand...
Both of the core upload and filefield modules have one very frustrating behavior: (I directly copied this statement from markDrupal's upload_replace module) If you have a file called "mydoc.doc" upload it to a node, then make changes to "mydoc.doc" and upload the newer version, the newer version will be renamed to "mydoc_0.doc" because at the time of upload the old file was blocking the desired path name.
This behavior is not intuitive to users used to dealing with document management systems. The name of the latest-and-greatest revision should not be augmented. The http://drupal.org/project/upload_replace module attempts to work around this shortcoming; however, it doesn't seem to play well with the filefield_paths and file_aliases modules.
I'm not sure if I'm "barking up the right tree", but the filefield module seems like the best place to start this conversation.
Also, I wanted to point out that the http://drupal.org/project/webfm module has a very nice method of dealing with this circumstance. (see attached screenshot). Unfortunately, that module has it's own set of issues and is not a good fit for our needs.
Can anyone point us in the right direction?
Many thanks in advance.
| Comment | File | Size | Author |
|---|---|---|---|
| #17 | upload_replace-code-and-support-filefield_paths-724464-16.patch | 7.67 KB | mogwaay |
| #11 | upload_replace-support-filefield_paths-724464-11.patch | 779 bytes | traviscarden |
| #8 | filefield_paths_integration-724464.patch | 3.9 KB | attheshow |
| #1 | webfm-filemgmtsample.JPG | 12.09 KB | stacysimpson |
Comments
Comment #1
stacysimpson commentedAnd now the screenshot
Comment #2
stacysimpson commentedMoving to the upload_replace module
Comment #3
tommyk commentedI made a note on #792760: Old aliases left behind after deleting revisions to try and bring these two issues together because I think there is potential for a solution to this issue between these two modules.
Comment #4
TripleEmcoder commentedSubscribing.
Comment #5
ajagadees commentedHi,
Am having the same problem above, I am using the http://drupal.org/project/filefield_paths for the folder structure. Please help me to solve the above issue (file gets renaming)
Comment #6
j d ess commentedSame problem. Integration with filefield_paths would be great. I really need to retain the file name and cannot rely on users to do it for me.
My workaround is:
Create node/Upload file > (...time passes) > Remove/Upload updated file > Save Node (file used at this point name_#.ext, i.e. the old version) > Save Node again (file is name.ext, i.e. the right version).
I can't really pass this on to an editor, though, since it is counter-intuitive.
Comment #7
attheshow commentedI haven't been able to get this working yet, but it's looking like we might be able to take advantage of hooks within the filefield_paths module to trigger the main function in upload_replace. Something like:
I'll let everyone know if I can get this working correctly.
Comment #8
attheshow commentedThe function below is working for me. Replace the code from #7 above with this. I've also attached a patch that includes this code.
Comment #9
greenskunk@attheshow ... wooooohoooooo!!!
For Drupal 6, your patch works to integrate filefield_paths with upload_replace! Two months ago, I had tried upload replace and only had a little time to see what could be conflicting or overriding another behavior. I've spent about 35 minutes testing, going through logs, different modules and then back to the upload_replace issue queue.
@everyone using this patch please post any issues here. I will be testing it more thoroughly in the next few days.
@markDrupal Would you add this as a known issue to the Upload Replace page and that there is currently a patch available for review?
Comment #10
endiku commented#8 patch works great. Haven't encountered any problems.
Comment #11
traviscarden commentedGreat job, @attheshow! I didn't test your patch for 6.x, but I adapted the approach for 7.x where I needed it, and it works great. I'm bumping the version here. We can backport later.* Here's a patch.
* For when we come back to it, I suspect you don't actually need to duplicate
filefield_paths_filefield_paths_process_file()in your patch. (I didn't have to in 7.x) But even if you do, you can just call it instead of copying its contents.Comment #12
tyler-durden commentedI added the patch in #11 to D7 and it works (no _0 files are being created and I verified the file is deleted/written over), but I get this error after saving.
Warning: Parameter 1 to upload_replace_file_update() expected to be a reference, value given in module_invoke_all() (line 850 of includes/module.inc)
I did not have this error before applying the patch.
Comment #13
traviscarden commented@tyler-durden: I believe that's a distinct issue that the patch exposes but does not cause: See #1115484: Parameter 1 to upload_replace_file_update() expected to be a reference, value given in module_invoke_all() . I have successfully eliminated the message on my site with the patch there in #13.
Comment #14
tyler-durden commentedTravisCarden, thanks. That patch removed the error for me also.
Comment #15
lias commentededited - removed
Comment #16
mogwaay commentedHi all,
I've tried to get both filefield_path and upload_replace modules to work nicely together, and applied #11 ontop of #20 from https://drupal.org/node/1115484 and they don't play nicely together.
I've included a patch that I used which combines
https://drupal.org/files/upload_replace-code-1115484-20.patch https://drupal.org/files/upload_replace-code-1115484-20.patch
in one.
I can upload the same file to a node a couple of times, but after that, I start getting duplicates files in the sites/defaults/files folder with the filefield_path name and the original name, both with _0 and not the actual path on the node - causing a 404. All the while I get SQL errors like:
Either on uploading the new file (ie, clicking Upload button after Browsing) or on Saving the node after uploading. If you get the error on the AJAX upload, you can submit again and it'll go through, if you get the error on edit, you can submit again and it'll go through - but every second time you Save the node the file link will break and your sites/defualt/files will show 2 sets of the file with the filefield_path name and the original file with _X at the end of each - but no version without!
Does anyone have this setup working?
(PS this is the first time I've uploaded a patch here and I'm not sure how to add it to this thread, please bear with me...)PSS Ah, it gets added as a separate comment, sorry if the numbers confuse anyone...
Comment #17
mogwaay commentedComment #18
mogwaay commentedbtw: I've given up using this module (upload_replace) to fix my problem and instead I just patched filefield_paths so that for one content type (foe_downloadables) it will remove any previous file with the same URI - my patch looks like this if anyone else is interested (sorry for the mad comment lines!):
If I had more time I would've added a new checkbox per-file-field that specified that it will delete any file that is parked on the URL that we want.
Hope it's useful for someone else struggling to maintain URLs and not having the _X added to the end of it.
Comment #19
elijah lynn