0

I'm lacking experience on the following issue and unfortunately it isn't documented explicitly. I'ld like to have a shared files folder for a handful of multi-sites. As those sites all represent sub-organisations of one and the same parent organisation it should be possible that all of them have access to the same files in one certain files subdirectory using a shared file manager like IMCE.

The only concrete clue I found is on https://www.drupal.org/node/53705. But this is about Drupal 5.

A /files directory could easily be shared across two domains without being shared across the remaining domains.

I wildly guess this didn't change much for following versions. But, have anybody ever tried it this way in production? Would you have any concerns doing it this way? What else could I consider to do instead?

As far as I've tested it right now this seems to work. Also images and files uploaded to image and file fields on site A stayed in the shared files folder even after multiple cron runs on site B and site C (as Clive noted to have a look at the file_usage logic).

I also then deleted the files and images from site A's nodes and run site A's cron multiple times. Still the files stayed there. But this simply might be a permission issue, maybe.

4
  • 2
    I smell danger...Drupal decides whether files can be deleted based on the file_usage table. If you remove a file from site A that site B is also using, it will be deleted by site A's cron run because it has no visibility of Site B's usage of it
    – Clive
    Commented Mar 22, 2017 at 10:18
  • @Clive - Thanks for the input. I've uploaded images and files to image and file fields on site A and they stayed in the shared files folder even after multiple cron runs on site B and site C.
    – leymannx
    Commented Mar 22, 2017 at 10:39
  • You'd need to remove the file from the field in site A and run the cron on site A too...that should delete the file, but sites B & C won't know about the change, so they'll still reference a now-deleted file. At least that's the theory, maybe there are other things operating on it that I'm not aware of
    – Clive
    Commented Mar 22, 2017 at 10:45
  • @Clive - This also is the theory I heard of. But until today I never could witness it. Also in single sites files always stayed in the files folder even after deleting them or the referencing nodes. At least that's my observation. But this simply might be a permission issue, maybe.
    – leymannx
    Commented Mar 22, 2017 at 10:55

1 Answer 1

1

This should not work. Managed files should be automatically removed once there are no more entries in the file_usage table for them. I see you say that it's not happening on your setup, but maybe that's a permission or some other issue. That's not how it's supposed to work.

I'm curious how you plan on this working, in any case. If you're using file fields, then Sites B and C would have no way to know that you uploaded a file to Site A, so how it is useful? You say that you're using a file manager. Is it like IMCE or something where you are just browsing the files by directory? If you upload a file through something like that, it wouldn't get an entry in the files_managed table, so it would not be automatically deleted. That would make sense.

1
  • Yes, through a file manager like IMCE.
    – leymannx
    Commented Mar 23, 2017 at 9:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.