Skip to content

Commit

Permalink
fix storage bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
ajspeck committed Apr 23, 2020
1 parent f9a3f64 commit 404ded2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
11 changes: 9 additions & 2 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@ services:
command: --default-authentication-plugin=mysql_native_password
environment:
- MYSQL_ROOT_PASSWORD=zotero
volumes:
- db_data:/var/lib/mysql
db-zotero-elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:5.3.0
environment:
- cluster.name=zotero
- xpack.security.enabled=false
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
db-zotero-redis:
image: redis:5.0
db-zotero-memcached:
Expand All @@ -23,6 +26,8 @@ services:
environment:
- MINIO_ACCESS_KEY=zotero
- MINIO_SECRET_KEY=zoterodocker
volumes:
- minio_data:/data
command: server /data
labels:
- "traefik.backend=zotero-s3"
Expand Down Expand Up @@ -61,7 +66,6 @@ services:
- db-zotero-memcached:memcached
- db-zotero-localstack:localstack
- db-zotero-minio:minio
restart: always
labels:
- "traefik.zotero.backend=zotero"
- "traefik.docker.network=web"
Expand All @@ -82,4 +86,7 @@ services:
- default
networks:
web:
external: true
external: true
volumes:
db_data: {}
minio_data: {}
5 changes: 1 addition & 4 deletions model/FullText.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ public static function indexItem(Zotero_Item $item, $data) {
$sql .= implode(", ", $fields) . ") VALUES ("
. implode(', ', array_fill(0, sizeOf($params), '?')) . ")";
Zotero_DB::query($sql, $params, Zotero_Shards::getByLibraryID($libraryID));

// Add to S3
$json = [
'libraryID' => $libraryID,
Expand All @@ -62,7 +61,6 @@ public static function indexItem(Zotero_Item $item, $data) {
'content' => (string) $data->content,
'timestamp' => str_replace(" ", "T", $timestamp)
];

foreach (self::$metadata as $prop) {
if (isset($data->$prop)) {
$json[$prop] = (int)$data->$prop;
Expand All @@ -71,15 +69,14 @@ public static function indexItem(Zotero_Item $item, $data) {

$json = json_encode($json, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
$json = gzencode($json);

$s3Client = Z_Core::$AWS->createS3();
$start = microtime(true);
$s3Client->putObject([
'Bucket' => Z_CONFIG::$S3_BUCKET_FULLTEXT,
'Key' => $libraryID . "/" . $key,
'Body' => $json,
'ContentType' => 'application/gzip',
'StorageClass' => strlen($json) < self::$minFileSizeStandardIA ? 'STANDARD' : 'STANDARD_IA'
'StorageClass' => 'STANDARD'
]);
StatsD::timing("s3.fulltext.put", (microtime(true) - $start) * 1000);

Expand Down
5 changes: 3 additions & 2 deletions model/Storage.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -689,8 +689,9 @@ public static function getUploadPOSTData($item, Zotero_StorageFileInfo $info) {
. "Content-Disposition: form-data; name=\"$key\"\r\n\r\n"
. $val . "\r\n";
}
$prefix .= "--$boundary\r\nContent-Disposition: form-data; name=\"file\"\r\n\r\n";

//$prefix .= "--$boundary\r\nContent-Disposition: form-data; name=\"file\"\r\n\r\n";
$prefix .= "--$boundary\r\nContent-Disposition: form-data; name=\"file\"; filename=\"binary\"\r\n\r\n";

// Suffix
$suffix = "\r\n--$boundary--";

Expand Down

0 comments on commit 404ded2

Please sign in to comment.