Compare commits
1 Commits
master
...
sha256-san
Author | SHA1 | Date | |
---|---|---|---|
a2ec23d667 |
73
get.php
73
get.php
@ -164,8 +164,7 @@ function uupGetFiles(
|
|||||||
if(isset($filesInfoList[$val])) unset($filesInfoList[$val]);
|
if(isset($filesInfoList[$val])) unset($filesInfoList[$val]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$sha256capable) {
|
$baseless = preg_grep('/^baseless_|Windows10\.0-KB.*-EXPRESS|SSU-.*-EXPRESS/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]);
|
||||||
}
|
}
|
||||||
@ -174,8 +173,8 @@ function uupGetFiles(
|
|||||||
$psf = preg_grep('/\.psf$/i', $psf);
|
$psf = preg_grep('/\.psf$/i', $psf);
|
||||||
|
|
||||||
$psfk = preg_grep('/Windows10\.0-KB.*/i', $psf);
|
$psfk = preg_grep('/Windows10\.0-KB.*/i', $psf);
|
||||||
$psfk = preg_grep('/.*-EXPRESS|.*-baseless/i', $psfk, PREG_GREP_INVERT);
|
$psfk = preg_grep('/.*-EXPRESS/i', $psfk, PREG_GREP_INVERT);
|
||||||
if($build > 21380) foreach($psfk as $key => $val) {
|
foreach($psfk as $key => $val) {
|
||||||
if(isset($psf[$key])) unset($psf[$key]);
|
if(isset($psf[$key])) unset($psf[$key]);
|
||||||
}
|
}
|
||||||
unset($psfk);
|
unset($psfk);
|
||||||
@ -201,7 +200,6 @@ function uupGetFiles(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
unset($removeFiles);
|
unset($removeFiles);
|
||||||
}
|
|
||||||
|
|
||||||
$filesInfoKeys = array_keys($filesInfoList);
|
$filesInfoKeys = array_keys($filesInfoList);
|
||||||
|
|
||||||
@ -381,9 +379,23 @@ function uupGetOnlineFiles($updateId, $rev, $info, $cacheRequests, $type) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if($sha256capable) {
|
if($sha256capable) {
|
||||||
$n = strrpos($name, '.');
|
$tempname = uupCleanSha256($name);
|
||||||
if($n === false) $n = strlen($name);
|
if(isset($files[$tempname])) {
|
||||||
$newName = substr($name, 0, $n).'_'.substr($sha1, 0, 8).substr($name, $n);
|
if(preg_match('/\.cab$/i', $tempname)) {
|
||||||
|
if($size > $files[$tempname]['size']) {
|
||||||
|
$express = 'baseless_'.$tempname;
|
||||||
|
$files[$express] = $files[$tempname];
|
||||||
|
unset($files[$tempname]);
|
||||||
|
$newName = $tempname;
|
||||||
|
} else {
|
||||||
|
$newName = 'baseless_'.$tempname;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$newName = uupAppendSha1($tempname, $sha1);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$newName = $tempname;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$newName = $uupCleanFunc($name);
|
$newName = $uupCleanFunc($name);
|
||||||
}
|
}
|
||||||
@ -450,9 +462,29 @@ function uupGetOfflineFiles($info) {
|
|||||||
$sha256 = isset($val['sha256']) ? $val['sha256'] : null;
|
$sha256 = isset($val['sha256']) ? $val['sha256'] : null;
|
||||||
|
|
||||||
if($sha256capable) {
|
if($sha256capable) {
|
||||||
$n = strrpos($name, '.');
|
// clean file name
|
||||||
if($n === false) $n = strlen($name);
|
$tempname = uupCleanSha256($name);
|
||||||
$newName = substr($name, 0, $n).'_'.substr($sha1, 0, 8).substr($name, $n);
|
if(isset($files[$tempname])) {
|
||||||
|
// check existing file with the same name
|
||||||
|
if(preg_match('/\.cab$/i', $tempname)) {
|
||||||
|
// compare cab files only
|
||||||
|
if($size > $files[$tempname]['size']) {
|
||||||
|
// if the existing file is smaller, rename it
|
||||||
|
$express = 'baseless_'.$tempname;
|
||||||
|
$files[$express] = $files[$tempname];
|
||||||
|
unset($files[$tempname]);
|
||||||
|
$newName = $tempname;
|
||||||
|
} else {
|
||||||
|
// if the new file is smaller, rename it
|
||||||
|
$newName = 'baseless_'.$tempname;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// not a cab file, append hash to differentiate
|
||||||
|
$newName = uupAppendSha1($tempname, $sha1);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$newName = $tempname;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$newName = $uupCleanFunc($name);
|
$newName = $uupCleanFunc($name);
|
||||||
}
|
}
|
||||||
@ -478,6 +510,25 @@ function uupGetOfflineFiles($info) {
|
|||||||
return $files;
|
return $files;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function uupAppendSha1($name, $sha1) {
|
||||||
|
$n = strrpos($name, '.');
|
||||||
|
if($n === false) $n = strlen($name);
|
||||||
|
return substr($name, 0, $n).'_'.substr($sha1, 0, 8).substr($name, $n);
|
||||||
|
}
|
||||||
|
|
||||||
|
function uupCleanSha256($name) {
|
||||||
|
$replace = array(
|
||||||
|
'MetadataESD_' => null,
|
||||||
|
'metadataesd_' => null,
|
||||||
|
'~31bf3856ad364e35' => null,
|
||||||
|
'~~.' => '.',
|
||||||
|
'~.' => '.',
|
||||||
|
'~' => '-',
|
||||||
|
);
|
||||||
|
|
||||||
|
return strtr($name, $replace);
|
||||||
|
}
|
||||||
|
|
||||||
function uupCleanName($name) {
|
function uupCleanName($name) {
|
||||||
$replace = array(
|
$replace = array(
|
||||||
'cabs_' => null,
|
'cabs_' => null,
|
||||||
|
Loading…
Reference in New Issue
Block a user