Hi,
one question that a lot of issues seem to cycle around - even without mentioning it - is, should files uploaded with IMCE be kept track of in the file_managed table?
The question behind that, does Drupal 'own' a files that users upload? What happens if the content that references the file is deleted?

The general Drupal philosophy appears to be, that any user file upload happens for a specific purpose, which Drupal knows about. When this purpose ceases to exist, the file can be deleted.
The design of the file_managed table and its API is based on this design idea.
Also, filefield (or just "file" field in D7) + filefield_sources are based on this idea.

There is a different thinkable philosophy, that is, files being uploaded without Drupal knowing about it.
This could be via ssh, ftp, dropbox or other means.
Files uploaded this way are not "owned" by Drupal, but they can still be "known" by Drupal or some contrib module.
Files can be added, moved, renamed or deleted, and Drupal will have no idea.
The IMCE CCK Image module was designed exactly for this purpose. That is, maybe the original maintainer did not see it like that, but I do :)

So, what about IMCE?
By the essence of its design, IMCE does not care how a file was uploaded. It just sees files and folders, no fids or the like.
However, I read that recent versions of IMCE become increasingly aware of how files are associated with content, how they are known to or owned by Drupal.
I also read that the *-2.x branch will always register uploaded files in the file_managed table.

I wonder where this is going.
I am about to produce a D7 version of imceimage, following the original philosophy I saw in the D6 version, but if IMCE now wants to store everything in file_managed, then this is a pointless effort.
(btw, yes, imceimage will have to deal with the scenario of orphan fields, where the file has been deleted)

-------

I think the best would be if IMCE would support both scenarios: Managed files, and files living in anarchy.
Allow people to configure their directories to have one place for managed, another for non-managed files.

All of this with the assumption that Drupal will delete a file, if usage count drops to zero.
Maybe it would be enough to add one "implicit" usage, whenever a file goes into the file_managed table that was not uploaded for a specific purpose? So the real usage count could drop to zero, and Drupal would not delete the file.
Still, we also have to consider the case where a file is deleted w/o Drupal knowing about it.

The first step is to become aware of the two realities I mentioned above, so future design decisions can be "enlightened".

Comments

donquixote’s picture

Btw, my own use case is the "upload with dropbox" scenario.

The user would
- share a few picture folders with Dropbox, so they are automatically uploaded to sites/default/files/dropbox (symlink)
- in Drupal: Create a new "album" node, use imceimage to pick a title image for that album.
- now, whenever the album is to be displayed, it will scandir() the location of the title picture, and display all the pics that are in the same folder.

If the folder is removed or renamed, the album needs to be fixed.
That's the price.

Other than those albums with orphan paths, this method does not leave any invisible junk in the database.

ufku’s picture

A file should be deleted by the interface that uploaded that file. IMCE registers files to prevent any other interface from deleting the files uploaded by IMCE.

What's the requested feature, by the way?

donquixote’s picture

Category: feature » support

Ah, did I make this a feature request. (:
The "I think the best would be" stuff could probably count as a feature request. But maybe that's not needed anymore.

A file should be deleted by the interface that uploaded that file. IMCE registers files to prevent any other interface from deleting the files uploaded by IMCE.

This seems pretty ok to me.
Does this also work in D6 ? Afaik, there is no file_usage in D6..

The main things I was trying to find out were:
- whether future versions of IMCE would still support "unmanaged" files.
- whether the motivation for imceimage does still apply in D7. Otherwise, no reason to have unmanaged files.

One "problem" of managed files is the database clean-up, if the file is being deleted via ftp or ssh. I am curious how this works, but I guess I can live with a bit of junk in the database.

After trying out your sandbox project, I am quite happy :)
http://drupal.org/sandbox/ufku/1373728

ufku’s picture

In D6 each module needs to maintain its own file usage table and report the usage when hook_file_references is called. IMCE registers its files in imce_files table.

- Unmanaged files will always be supported.
- I think imceimage should have been implemented similar to IMCE for Filefield in the first place.

ufku’s picture

Status: Active » Closed (fixed)