mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-20 00:55:19 +00:00
partial fix for failure to sync photos - appears to be memory exhaustion and dependent on filesize although an unrelated issue was found with directory creation during file sync (we didn't check ownership when looking for duplicates).
This checkin provides the means for a sync process to fetch the contents for various photo scales from the original server just as is done for the attach data now. It is still missing the bit for the sync process to spawn a mob of children to fetch these suckers and update the photo table with the results.
This commit is contained in:
parent
9dbd997141
commit
2e692fca93
2 changed files with 38 additions and 2 deletions
|
@ -35,6 +35,7 @@ class Getfile extends \Zotlabs\Web\Controller {
|
|||
$sig = $_POST['signature'];
|
||||
$resource = $_POST['resource'];
|
||||
$revision = intval($_POST['revision']);
|
||||
$resolution = (-1);
|
||||
|
||||
if(! $hash)
|
||||
killme();
|
||||
|
@ -46,6 +47,11 @@ class Getfile extends \Zotlabs\Web\Controller {
|
|||
killme();
|
||||
}
|
||||
|
||||
if(substr($resource,-2,1) == '-') {
|
||||
$resolution = intval(substr($resource,-1,1));
|
||||
$resource = substr($resource,0,-2);
|
||||
}
|
||||
|
||||
$slop = intval(get_pconfig($channel['channel_id'],'system','getfile_time_slop'));
|
||||
if($slop < 1)
|
||||
$slop = 3;
|
||||
|
@ -63,6 +69,35 @@ class Getfile extends \Zotlabs\Web\Controller {
|
|||
killme();
|
||||
}
|
||||
|
||||
|
||||
if($resolution > 0) {
|
||||
$r = q("select * from photo where resource_id = '%s' and uid = %d limit 1",
|
||||
dbesc($resource),
|
||||
intval($channel['channel_id'])
|
||||
);
|
||||
if($r) {
|
||||
header('Content-type: ' . $r[0]['mimetype']);
|
||||
|
||||
if(intval($r[0]['os_storage'])) {
|
||||
$fname = dbunescbin($r[0]['content']);
|
||||
if(strpos($fname,'store') !== false)
|
||||
$istream = fopen($fname,'rb');
|
||||
else
|
||||
$istream = fopen('store/' . $channel['channel_address'] . '/' . $fname,'rb');
|
||||
$ostream = fopen('php://output','wb');
|
||||
if($istream && $ostream) {
|
||||
pipe_streams($istream,$ostream);
|
||||
fclose($istream);
|
||||
fclose($ostream);
|
||||
}
|
||||
}
|
||||
else {
|
||||
echo dbunescbin($r[0]['content']);
|
||||
}
|
||||
}
|
||||
killme();
|
||||
}
|
||||
|
||||
$r = attach_by_hash($resource,$channel['channel_hash'],$revision);
|
||||
|
||||
if(! $r['success']) {
|
||||
|
|
|
@ -1084,11 +1084,12 @@ function sync_files($channel, $files) {
|
|||
$ext = '';
|
||||
}
|
||||
|
||||
$r = q("select filename from attach where ( filename = '%s' OR filename like '%s' ) and folder = '%s' and hash != '%s' ",
|
||||
$r = q("select filename from attach where ( filename = '%s' OR filename like '%s' ) and folder = '%s' and hash != '%s' and uid = %d ",
|
||||
dbesc($basename . $ext),
|
||||
dbesc($basename . '(%)' . $ext),
|
||||
dbesc($att['folder']),
|
||||
dbesc($att['hash'])
|
||||
dbesc($att['hash']),
|
||||
intval($channel['channel_id'])
|
||||
);
|
||||
|
||||
if($r) {
|
||||
|
|
Loading…
Reference in a new issue