regulate files names

append sha1 name suffix for the smaller duplicate file, thus unify the result for findfiles/get
This commit is contained in:
abbodi1406 2022-06-17 02:00:48 +03:00 committed by GitHub
parent 47b7ee6703
commit a3c35f89fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

14
get.php
View File

@ -420,7 +420,14 @@ function uupGetOnlineFiles($updateId, $rev, $info, $cacheRequests, $type) {
if($sha256capable) { if($sha256capable) {
$tempname = uupCleanSha256($name); $tempname = uupCleanSha256($name);
if(isset($files[$tempname])) { if(isset($files[$tempname])) {
if($size > $files[$tempname]['size']) {
$smaller = uupAppendSha1($tempname, $files[$tempname]['sha1']);
$files[$smaller] = $files[$tempname];
unset($files[$tempname]);
$newName = $tempname;
} else {
$newName = uupAppendSha1($tempname, $sha1); $newName = uupAppendSha1($tempname, $sha1);
}
} else { } else {
$newName = $tempname; $newName = $tempname;
} }
@ -492,7 +499,14 @@ function uupGetOfflineFiles($info) {
if($sha256capable) { if($sha256capable) {
$tempname = uupCleanSha256($name); $tempname = uupCleanSha256($name);
if(isset($files[$tempname])) { if(isset($files[$tempname])) {
if($size > $files[$tempname]['size']) {
$smaller = uupAppendSha1($tempname, $files[$tempname]['sha1']);
$files[$smaller] = $files[$tempname];
unset($files[$tempname]);
$newName = $tempname;
} else {
$newName = uupAppendSha1($tempname, $sha1); $newName = uupAppendSha1($tempname, $sha1);
}
} else { } else {
$newName = $tempname; $newName = $tempname;
} }