Skip to content

Commit 5eca5e2

Browse files
committed
Related to #7, creates timestamped jsons before adding to tar and disables compression due to phar issue: https://bugs.php.net/bug.php?id=71555
1 parent 7406a98 commit 5eca5e2

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

controller/controller.php

+5-2
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ function my_push() {
370370
continue;
371371
}
372372
//Make sure that we already have the posts file in the DB.
373-
$sql="SELECT page_fb_id, post_fb_id, CONCAT(page_fb_id , '_' , DATE_FORMAT(date,'%Y-%m-%dT%H'),'_',page_fb_id,'_',post_fb_id,'.json')".
373+
$sql="SELECT page_fb_id, post_fb_id, CONCAT(page_fb_id , '_' , DATE_FORMAT(date,'%Y-%m-%dT%H'),'_',page_fb_id,'_',post_fb_id)".
374374
" AS fname, REPLACE(name,' ','_') AS archive, fb_id FROM post,page WHERE page_fb_id=fb_id AND page_fb_id=".$dbPDO->quote(strstr($post['id'],'_',true)).
375375
" AND post_fb_id=".$dbPDO->quote(substr(strstr($post['id'],'_'),1));
376376
$result = $dbPDO->query($sql);
@@ -380,7 +380,7 @@ function my_push() {
380380
$lock = $dbPDO->query("SELECT GET_LOCK(".$dbPDO->quote($archive).", 30);")->fetchAll()[0][0];
381381
if($lock != 1) //Unable to get lock.
382382
die("Unable to get lock for: " . $archive);
383-
if(!phar_put_contents($row['fname'], $archive, $post['data']))
383+
if(!phar_put_contents($row['fname'].'#'.microtime(true).'.json', $archive, $post['data']))
384384
die("Unable to write the file: " . $row['fname']);
385385
//continue; //We did not manage to write to our phar archive, try with next post.
386386

@@ -552,11 +552,14 @@ function phar_put_contents($fname, $archive, $data) {
552552
$newName = $archive.'-'.time();
553553
//Move archive to archive-EPOC.tar
554554
rename($archive.'.tar', $newName.'.tar');
555+
/*
555556
//Compress.
556557
$p = new PharData($newName.'.tar',0);
557558
$p->compress(Phar::GZ);
558559
rename($newName.'.tar.gz', dirname($newName.'.tar').'/gz/'.basename($newName).'.tar.gz');
559560
unlink($newName.'.tar');
561+
*/
562+
rename($newName.'.tar', dirname($newName.'.tar').'/tar/'.basename($newName).'.tar');
560563
}
561564
file_put_contents('/mnt/ramdisk/'.$fname, $data);
562565
$tarCmd = "tar ". (file_exists($archive.".tar") ? "-rf ":"-cf ") .$archive.".tar -C /mnt/ramdisk ".$fname;

0 commit comments

Comments
 (0)