-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove filename from storageFiles #55
base: master
Are you sure you want to change the base?
Conversation
} | ||
else { | ||
$response = Zotero_Storage::downloadFile($info, $downloadDir, $realFilename); | ||
} | ||
if ($response) { | ||
if ($zip) { | ||
$success = self::extractZip($downloadDir . $info['filename'], $dir); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we create a random dir, I think there is no difference what filename the zip file has.
We need a script to point all storageFileItems files that have the same hash, to the same (lowest storageFileID) row in storageFiles. There are a few options how it could be implemented. Option 1: Option 2: Option 3: There is an unused 'getFileItems' function that is unimplemented: link. Now when we have storageFileLibraries table this function would be much easier to implement if needed. Or we should remove it if no longer needed. |
model/Storage.inc.php
Outdated
@@ -531,8 +574,8 @@ public static function getFileItems($hash, $filename, $zip) { | |||
|
|||
|
|||
public static function addFile(Zotero_StorageFileInfo $info) { | |||
$sql = "INSERT INTO storageFiles (hash, filename, size, zip) VALUES (?,?,?,?)"; | |||
return Zotero_DB::query($sql, array($info->hash, $info->filename, $info->size, (int) $info->zip)); | |||
$sql = "INSERT INTO storageFiles (hash, `size`, zip) VALUES (?,?,?)"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the backticks? size
isn't a reserved word, as far as I know.
if ($e->getAwsErrorCode() == 'NoSuchKey' || $e->getAwsErrorCode() == 'NotFound') { | ||
$contents = $result->get('Contents'); | ||
if (!$contents || count($contents) < 1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are the possible values for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It returns all keys that are prefixed with a given hash. In our case:
hash
hash/file1
hash/c/file1
We should be able to eliminate |
…eld; remove 'getFileByHash' remove unnecessary backticks; remove any 'storageFiles' filtering on 'zip' or 'filename' fields
When uploading a file the original code was copying 'hash/filename1' to 'hash' on S3 if 'hash' doesn't exist. |
I think we should completely eliminate |
This |
'filename' column should be removed from storageDownloadLog and storageUploadLog too, because they depend on storageFiles table.
For those tables a default 'filename' value must be set.
storageFiles
storageDownloadLog
storageUploadLog