I'm sure I'm missing something stupid simple... but I just installed filemanager/attachment specifically for the unique namespace per node feature but my attachments on different nodes are being saved to the same directory. I checked readme/install files and adming/settings-- but i can't find any way to turn this feature on.
What am I missing?
Any help would be greatly appreciated-- I need to get this working before unleashing my users and uploading a bazillion files, LOL.
Thanks....
Comments
Comment #1
cscsteve commentedYou're not missing anything, other than perhaps thinking the functionality is larger than it is.
"Unique namespace per node" per the module description is not as fancy as you're thinking. It doesn't create a unique file directory per node (which would really cause problems actually, there's a limit to the number of directories a directory can hold), it continues to use the existing directories, adding new ones as needed as others fill up. Basically the logic is:
* Are you adding a file to a node that already has that file? Replace it.
* Are you adding a file?
- Check the first directory that has space. Does this dir have a file named this already? No, then put the file here.
- Go to the next dir that has space, repeat above question.
So, what is meant is that if you attach a new file to a new node, that filename won't conflict with a same named file on a different node. But it won't necessarily go in different directories simply because the nodes are different.
I hope that helps clarify.
- Steve
Comment #2
WorldFallz commentedLOL-- all I can say is DUH. Sometimes my mind is just too literal. Thanks for the prompt reply and information. One question, the replace file feature-- which I discovered by accident while i was playing around with it right after posting my question. I did it so easily, that I fear my users will too. One thing I noticed, was that "both" files were listed as individual attachments on the page, but in actuality there was only one file stored, it was the new one, and both links pointed to the same file. That seems a bug to me because 2 files listed on the page implies both files stored in the directory.
Would you be adverse to me posting a patch that would accept the duplicate and give it an incremental version number? I'm currently trying to cobble together a rudimentary document management system and this would be in keeping with that concept.
Let me know what you think. I'll probably do it for my installation anyway, but not patching your module just means I have to keep mine updated separately.
Comment #3
cscsteve commentedI had to try it myself and peek at the code before I was able to answer your question. :)
I'd love a patch. I agree, it definitely shouldn't show two links to the same file. Definitely a bug. I'll log that as a new bug in the tracker. If you'd like to post a patch to fix this specific issue, that would be most welcome. Logged as: http://drupal.org/node/173391
Perhaps it's time to add "revisions" to the file tracking. I'd guess that functionality should go into the Filemanager module, as it's more of a back-end sort of thing. I've added a feature request to Filemanager with specifics of how I'd like it to work. Feel free to discuss or post patches in that thread. http://drupal.org/node/173402
I'm going to call this "by design" on this node. :) Yes, I prefer everything organized into it's own little boxes. :)
Thanks,
- Steve
Comment #4
WorldFallz commentedOk great-- I'll take a look at the code for both modules and see if I can find where it makes the most sense to address the issue. As soon as I have something I'll post it to the appropriate place.
Comment #5
WorldFallz commentedOk, I took a look at the code for both modules. Both do things like "check for existing file" and deciding what to do about it. However, I think I'm leaning toward doing the attachment versioning in this module around line 351 in the attachment_add function for the following reason:
The "versions" are really connected to the node, not the file store. We're not talking about handling a file name conflict with a duplicate file in the file system-- like attachments with the same name on different nodes (which may or may not be versions of the same file). This case is already handled anyway with the separate namespace for separate nodes feature. In this case, more likely than not, because they are on 2 different nodes, they are 2 completely different files that just happen to have the same name by accident.
But what we are talking about is handling a file name conflict with 2 file attachments on the same node. In this case, as opposed to the other case above, 2 files with the same exact name on the same exact node are more likely to be different versions of the same file which is why I think the code belongs in attachment not filemanager.
But let me know what you think... I'm planning to work on it this weekend.
Comment #6
cscsteve commentedI'd rather the functionality gets added to the Filemanager API. A few new functions, and a few minor mods to existing functions, and then adding the use of that new API to Attachment should do the trick. This way every module that uses the API would be able to benefit. Filemanager (AFAIK) is the one that currently decides if a file is to be replaced because it's the same node, so this doesn't seem like a stretch to me.
That said, I haven't looked at the code in either module with an eye to this feature yet. Perhaps you're right. If you send me a patch vs. Attachment only, I will still look at it and review it. If it looks like the right approach, then I'll commit it. I'm just trying to "do it right". :)
Convince me. :)
Thanks,
- Steve
Comment #7
WorldFallz commentedGood point about other apps benefiting-- that didn't occur to me. There's actually places in both modules where this logic appears (might be the source of the bug I stumbled on, but I dont know yet). I don't think it's going to be too complicated to do--- shouldn't be more than a couple of lines of code. I'll try to do a quick patch for both. Then you (and perhpas the filemanager maintainer) can take a look at both approaches and see where it "feels" right---
Comment #8
cscsteve commentedWell, it'll be easy since I am the Filemanager maintainer. :)
For the double link bug, please put your patch on this issue:
http://drupal.org/node/173391
For the Filemanager portion of revisions, please see:
http://drupal.org/node/173402
Thanks,
- Steve
Comment #9
WorldFallz commentedit's actually more complicated then i first thought. I did a more thorough read of code for both modules, and it definitely seems like filemanager is already trying to address the situation (check out the code that begins on line 948) exactly as I proposed (with incremental file names). Obviously, though, it's just not working that way so it'd definitely a bug. I'm using a WAMP drupal install, so that might have something to do it. I've encountered some bugs before having to do file handling on a WAMP drupal. Still working on it though.
Comment #10
WorldFallz commentedI can confirm that the patch at http://drupal.org/node/64742 fixes the bug of having the same file appear as 2 attachments. I would definitely add it to the next version. It's only one line of code.
So what we have now, is that when a user attaches a file of the same exact name to a node that already has a file attachment, it just overwrites the file and it is displayed properly.
So the "bug" is fixed. But the possibility for a user to unwittingly lose a file still exists. Normally "overwriting" something usually requires a confirmation so the user understand what they are doing.
However, being a recycled usability engineer, i can't help but think this is a disaster waiting to happen (at least with my users).
There's 2 ways to handle this:
1) just provide a confirmation so the user understands they will lose the existing file if they don't rename the file they are attaching
or
2) simply append a numeral to the file and add it as an additional attachment.
The first one is easier, the second one may be more preferred by the users.
Opinions? Or am I the only one that cares, lol.