Closed (fixed)
Project:
S3 File System
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
30 Jun 2014 at 15:42 UTC
Updated:
14 Jul 2015 at 11:44 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
geodaniel commentedPatch attached which should do the trick.
Comment #2
coredumperror commentedThat character set setting is essential to the operation of s3fs (it makes the 'uri' field case sensitive), but your patch takes it away from non-MySQL databases. Is that OK? I know nothing about PostgreSQL.
The reason that alter table call is even needed is because of a bug in Drupal's database driver that prevents the 'collation' setting in s3fs's
hook_schema()implementation from being applied. Looking at the PostgreSQL driver, it doesn't appear to mention collation at all, and I'm not sure why.If PostrgeSQL is inherently case-sensitive, then I suppose setting a collation (if that's even possible) isn't useful. Which would make your patch just fine.
Comment #3
geodaniel commentedI've had a bit of a read around, and it seems like Postgres is case sensitive by default, and SQLite is too, so they don't need to run this ALTER statement.
The attached patch also checks the database type when creating the s3fs_file_temp table, which was preventing the library from being used on a Postgres site.
With the patch, I can successfully store files in my S3 bucket, and I can upload files with different capitalisation of the same name (e.g. TEST.jpg and test.jpg both work). I haven't tested this on a SQLite database.
Comment #4
coredumperror commentedLooks good to me! Just pushed this up to git.
Comment #6
geodaniel commentedThanks!
Comment #8
edaa commentedAnother way to solve the collation issue is:
Note: 'binary' => TRUE, is added, see 'file_managed' schema definition in system.install.
Comment #9
coredumperror commentedI dunno... that seems like it might not be the best idea. The 'binary' => TRUE mechanism is implemented by making the column BINARY, which (as I understand it) prevents indexing. I'm not really up-to-snuff on low-level database stuff like that, though, so maybe it's OK? Interestingly enough, the docs do not accurately describe what this flag does.
:30 minutes of research later:
OK, so I think that a
VARCHAR (50) BINARYcolumn is actually identical to aVARCHAR (50) CHARACTER SET utf8_bincolumn. Maybe. The docs don't make this remotely clear (they don't even describe whatVARCHAR (50) BINARYactually means), so I'm forced to assume it means the same thing asVARBINARY (50)(based on some StackOverflow answers I found).So I think you're right that changing the hook_schema() implementation to use 'binary' => TRUE is the right way to do this. But then the question becomes: "Is that a safe thing to change for existing users?" I'll have to do some testing. Fortunately, the big project I've been working on is currently on a short hiatus, so I actually have time!
Comment #10
coredumperror commentedHah, well there we go! Turns out that executing
ALTER TABLE s3fs_file CHANGE uri uri VARCHAR(255) BINARYactually just sets the column toCOLLATE utf8_bin. So that means'binary' => TRUEhas been the right answer all along, and I just never discovered it in the API docs. Silly me. I've pushed a new dev version that converts to use'binary' => TRUE.Comment #11
edaa commentedThanks, a discussion: DB Case Sensitivity: Allow BINARY attribute in MySQL