forked from uup-dump/api
Fix missing duplicate files
if 2nd file size < 1st file size, it's mistakenly skipped e.g. Microsoft-Windows-Client-LanguagePack-Package multiple files
This commit is contained in:
parent
9bf6353bf6
commit
852a5d7d85
62
get.php
62
get.php
@ -159,17 +159,17 @@ function uupGetFiles(
|
|||||||
return $filesInfoList;
|
return $filesInfoList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$diffs = preg_grep('/.*_Diffs_.*|.*_Forward_CompDB_.*|\.cbsu\.cab$/i', array_keys($filesInfoList));
|
||||||
|
foreach($diffs as $val) {
|
||||||
|
if(isset($filesInfoList[$val])) unset($filesInfoList[$val]);
|
||||||
|
}
|
||||||
|
|
||||||
if(!$sha256capable) {
|
if(!$sha256capable) {
|
||||||
$baseless = preg_grep('/^baseless_|-baseless\....$/i', array_keys($filesInfoList));
|
$baseless = preg_grep('/^baseless_|-baseless\....$/i', array_keys($filesInfoList));
|
||||||
foreach($baseless as $val) {
|
foreach($baseless as $val) {
|
||||||
if(isset($filesInfoList[$val])) unset($filesInfoList[$val]);
|
if(isset($filesInfoList[$val])) unset($filesInfoList[$val]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$diffs = preg_grep('/.*_Diffs_.*|.*_Forward_CompDB_.*|\.cbsu\.cab$/i', array_keys($filesInfoList));
|
|
||||||
foreach($diffs as $val) {
|
|
||||||
if(isset($filesInfoList[$val])) unset($filesInfoList[$val]);
|
|
||||||
}
|
|
||||||
|
|
||||||
$psf = array_keys($filesInfoList);
|
$psf = array_keys($filesInfoList);
|
||||||
$psf = preg_grep('/\.psf$/i', $psf);
|
$psf = preg_grep('/\.psf$/i', $psf);
|
||||||
|
|
||||||
@ -254,7 +254,8 @@ function uupGetFiles(
|
|||||||
$name = $val;
|
$name = $val;
|
||||||
$newFiles[$name] = $filesInfoList[$name];
|
$newFiles[$name] = $filesInfoList[$name];
|
||||||
} else {
|
} else {
|
||||||
$failedFile = $val;
|
$failedFile = true;
|
||||||
|
consoleLogger("Missing file: $val");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -265,13 +266,13 @@ function uupGetFiles(
|
|||||||
if(isset($filesInfoList[$name])) {
|
if(isset($filesInfoList[$name])) {
|
||||||
$newFiles[$name] = $filesInfoList[$name];
|
$newFiles[$name] = $filesInfoList[$name];
|
||||||
} else {
|
} else {
|
||||||
$failedFile = $name;
|
$failedFile = true;
|
||||||
|
consoleLogger("Missing file: $name");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($failedFile) {
|
if($failedFile) {
|
||||||
consoleLogger("Missing file: $failedFile");
|
|
||||||
return array('error' => 'MISSING_FILES');
|
return array('error' => 'MISSING_FILES');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -379,9 +380,17 @@ function uupGetOnlineFiles($updateId, $rev, $info, $cacheRequests, $type) {
|
|||||||
$size = $info[$sha1]['size'];
|
$size = $info[$sha1]['size'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!isset($fileSizes[$name])) $fileSizes[$name] = -2;
|
if($sha256capable) {
|
||||||
|
$n = strrpos($name, '.');
|
||||||
|
if($n === false) $n = strlen($name);
|
||||||
|
$newName = substr($name, 0, $n).'_'.substr($sha1, 0, 8).substr($name, $n);
|
||||||
|
} else {
|
||||||
|
$newName = $uupCleanFunc($name);
|
||||||
|
}
|
||||||
|
|
||||||
if($size > $fileSizes[$name]) {
|
if(!isset($fileSizes[$newName])) $fileSizes[$newName] = -2;
|
||||||
|
|
||||||
|
if($size > $fileSizes[$newName]) {
|
||||||
preg_match('/P1=(.*?)&/', $url, $expire);
|
preg_match('/P1=(.*?)&/', $url, $expire);
|
||||||
if(isset($expire[0])) {
|
if(isset($expire[0])) {
|
||||||
$expire = $expire[1];
|
$expire = $expire[1];
|
||||||
@ -396,7 +405,7 @@ function uupGetOnlineFiles($updateId, $rev, $info, $cacheRequests, $type) {
|
|||||||
unset($temp);
|
unset($temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
$fileSizes[$name] = $size;
|
$fileSizes[$newName] = $size;
|
||||||
|
|
||||||
$temp = array();
|
$temp = array();
|
||||||
$temp['sha1'] = $sha1;
|
$temp['sha1'] = $sha1;
|
||||||
@ -407,14 +416,6 @@ function uupGetOnlineFiles($updateId, $rev, $info, $cacheRequests, $type) {
|
|||||||
$temp['expire'] = $expire;
|
$temp['expire'] = $expire;
|
||||||
$temp['debug'] = $val->asXML();
|
$temp['debug'] = $val->asXML();
|
||||||
|
|
||||||
if($sha256capable) {
|
|
||||||
$n = strrpos($name, '.');
|
|
||||||
if($n === false) $n = strlen($name);
|
|
||||||
$newName = substr($name, 0, $n).'_'.substr($sha1, 0, 8).substr($name, $n);
|
|
||||||
} else {
|
|
||||||
$newName = $uupCleanFunc($name);
|
|
||||||
}
|
|
||||||
|
|
||||||
$files[$newName] = $temp;
|
$files[$newName] = $temp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -447,10 +448,19 @@ function uupGetOfflineFiles($info) {
|
|||||||
$name = $val['name'];
|
$name = $val['name'];
|
||||||
$size = $val['size'];
|
$size = $val['size'];
|
||||||
$sha256 = isset($val['sha256']) ? $val['sha256'] : null;
|
$sha256 = isset($val['sha256']) ? $val['sha256'] : null;
|
||||||
if(!isset($fileSizes[$name])) $fileSizes[$name] = 0;
|
|
||||||
|
|
||||||
if($size > $fileSizes[$name]) {
|
if($sha256capable) {
|
||||||
$fileSizes[$name] = $size;
|
$n = strrpos($name, '.');
|
||||||
|
if($n === false) $n = strlen($name);
|
||||||
|
$newName = substr($name, 0, $n).'_'.substr($sha1, 0, 8).substr($name, $n);
|
||||||
|
} else {
|
||||||
|
$newName = $uupCleanFunc($name);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!isset($fileSizes[$newName])) $fileSizes[$newName] = 0;
|
||||||
|
|
||||||
|
if($size > $fileSizes[$newName]) {
|
||||||
|
$fileSizes[$newName] = $size;
|
||||||
|
|
||||||
$temp = array();
|
$temp = array();
|
||||||
$temp['sha1'] = $sha1;
|
$temp['sha1'] = $sha1;
|
||||||
@ -461,14 +471,6 @@ function uupGetOfflineFiles($info) {
|
|||||||
$temp['expire'] = 0;
|
$temp['expire'] = 0;
|
||||||
$temp['debug'] = null;
|
$temp['debug'] = null;
|
||||||
|
|
||||||
if($sha256capable) {
|
|
||||||
$n = strrpos($name, '.');
|
|
||||||
if($n === false) $n = strlen($name);
|
|
||||||
$newName = substr($name, 0, $n).'_'.substr($sha1, 0, 8).substr($name, $n);
|
|
||||||
} else {
|
|
||||||
$newName = $uupCleanFunc($name);
|
|
||||||
}
|
|
||||||
|
|
||||||
$files[$newName] = $temp;
|
$files[$newName] = $temp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user