Skip to content

Commit

Permalink
Media Migration tool adjustment
Browse files Browse the repository at this point in the history
- Adjust target
  • Loading branch information
egbot committed Feb 27, 2023
1 parent 20855f0 commit 4845d06
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions classes/MediaResolutionTools.php
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,6 @@ public function migrateFieldDerivatives($imgIdStart, $limit){
public function migrateCollectionDerivatives($imgIdStart, $limit){
//Migrates images based on catalog number; NULL or weak catalogNumbers are skipped
ini_set('max_execution_time', 3600);
$this->debugMode = true;
if($this->collid && is_numeric($limit) && $this->imgRootUrl && $this->imgRootPath){
if($this->transferThumbnail || $this->transferWeb || $this->transferLarge){
if($this->matchTermThumbnail || $this->matchTermWeb || $this->matchTermLarge){
Expand Down Expand Up @@ -279,21 +278,21 @@ public function migrateCollectionDerivatives($imgIdStart, $limit){
$rs = $this->conn->query($sql);
while($r = $rs->fetch_object()){
$imgIdStart = $r->imgid;
if(preg_match('/^\D*(\d+)$/',$r->catalognumber,$m)){
$catNum = $m[1];
if(preg_match('/^(\D*)(\d+)$/',$r->catalognumber,$m)){
$catNum = $m[2];
if(!$catNum) continue;
if(strlen($catNum)<8) $catNum = str_pad($catNum,8,'0',STR_PAD_LEFT);
$pathFrag = substr($catNum,0,strlen($catNum)-4).'/';
$pathFrag = $m[1].substr($catNum,0,strlen($catNum)-4).'/';
if(!file_exists($this->imgRootPath.$pathFrag)) mkdir($this->imgRootPath.$pathFrag);
if($this->debugMode) $this->logOrEcho($processingCnt.': Processing: <a href="../../individual/index.php?occid='.$r->occid.'" target="_blank">'.$r->occid.'</a>');
$this->logOrEcho($processingCnt.': Processing: <a href="../../individual/index.php?occid='.$r->occid.'" target="_blank">'.$r->occid.'</a>');
if($this->transferThumbnail){
$fileName = basename($r->thumbnailurl);
$targetPath = $this->imgRootPath.$pathFrag.$fileName;
$targetUrl = $this->imgRootUrl.$pathFrag.$fileName;
$thumbPath = $this->getLocalPath($r->thumbnailurl);
if(copy($thumbPath, $targetPath)){
$imgArr[$r->imgid]['tn'] = $targetUrl;
if($this->debugMode) $this->logOrEcho('Copied: '.$thumbPath.' => '.$targetPath,1);
$this->logOrEcho('Copied: '.$thumbPath.' => '.$targetPath,1);
if($this->deleteSource){
if(unlink($thumbPath)){
$this->logOrEcho('Source deleted: '.$thumbPath,1);
Expand All @@ -311,7 +310,7 @@ public function migrateCollectionDerivatives($imgIdStart, $limit){
$urlPath = $this->getLocalPath($r->url);
if(copy($urlPath, $targetPath)){
$imgArr[$r->imgid]['web'] = $targetUrl;
if($this->debugMode) $this->logOrEcho('Copied: '.$urlPath.' => '.$targetPath,1);
$this->logOrEcho('Copied: '.$urlPath.' => '.$targetPath,1);
if($this->deleteSource){
if(unlink($urlPath)){
$this->logOrEcho('Source delete: '.$urlPath,1);
Expand All @@ -329,7 +328,7 @@ public function migrateCollectionDerivatives($imgIdStart, $limit){
$origPath = $this->getLocalPath($r->originalurl);
if(copy($origPath, $targetPath)){
$imgArr[$r->imgid]['lg'] = $targetUrl;
if($this->debugMode) $this->logOrEcho('Copied: '.$origPath.' => '.$targetPath,1);
$this->logOrEcho('Copied: '.$origPath.' => '.$targetPath,1);
if($this->deleteSource){
if(unlink($origPath)){
$this->logOrEcho('Source deleted: '.$origPath,1);
Expand Down

0 comments on commit 4845d06

Please sign in to comment.