|
|
|
@ -172,12 +172,15 @@ eof;
@@ -172,12 +172,15 @@ eof;
|
|
|
|
|
|
|
|
|
|
$maxScanDeep = 0; //最大扫描目录级数 |
|
|
|
|
$dirTree = $scanner->scan($dirpath, $maxScanDeep); |
|
|
|
|
$this->updateAllDirTreeCache($dirTree); |
|
|
|
|
|
|
|
|
|
$scanResults = $scanner->getScanResults(); |
|
|
|
|
echo 'Total directories or files: ' . count($scanResults); |
|
|
|
|
echo "\n"; |
|
|
|
|
|
|
|
|
|
//统计文件数量 |
|
|
|
|
$dirId = $scanner->getId($dirpath); |
|
|
|
|
$this->updateAllDirTreeCache($dirId, $scanResults); |
|
|
|
|
|
|
|
|
|
$supportedImageExts = FSC::$app['config']['supportedImageExts']; |
|
|
|
|
$supportedVideoExts = FSC::$app['config']['supportedVideoExts']; |
|
|
|
|
$supportedAudioExts = FSC::$app['config']['supportedAudioExts']; |
|
|
|
@ -409,7 +412,7 @@ eof;
@@ -409,7 +412,7 @@ eof;
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected function updateAllDirTreeCache($dirTree) { |
|
|
|
|
protected function updateAllDirTreeCache($dirId, $dirTree) { |
|
|
|
|
$cacheKey = $this->allDirTreeCacheKey; |
|
|
|
|
$cacheData = Common::getCache($cacheKey); |
|
|
|
|
if (empty($cacheData)) { |
|
|
|
@ -417,52 +420,64 @@ eof;
@@ -417,52 +420,64 @@ eof;
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$cacheData = array_merge($cacheData, $dirTree); |
|
|
|
|
|
|
|
|
|
$pid = ''; |
|
|
|
|
$imgNum = $videoNum = $audioNum = 0; |
|
|
|
|
if (empty($cacheData[$dirId])) { |
|
|
|
|
$cacheData[$dirId] = $dirTree; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$supportedImageExts = FSC::$app['config']['supportedImageExts']; |
|
|
|
|
$supportedVideoExts = FSC::$app['config']['supportedVideoExts']; |
|
|
|
|
$supportedAudioExts = FSC::$app['config']['supportedAudioExts']; |
|
|
|
|
$imgNum = $videoNum = $audioNum = 0; |
|
|
|
|
foreach ($dirTree as $id => $item) { |
|
|
|
|
if (empty($item['pid'])) { |
|
|
|
|
break; |
|
|
|
|
echo "Ignored file no pid: {$id}\n"; |
|
|
|
|
print_r($item); |
|
|
|
|
echo "\n"; |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//TODO: 递归更新所有父目录 |
|
|
|
|
$pid = $item['pid']; |
|
|
|
|
if (!isset($cacheData[$pid]['image_total'])) { |
|
|
|
|
$cacheData[$pid]['image_total'] = 0; |
|
|
|
|
} |
|
|
|
|
if (!isset($cacheData[$pid]['video_total'])) { |
|
|
|
|
$cacheData[$pid]['video_total'] = 0; |
|
|
|
|
} |
|
|
|
|
if (!isset($cacheData[$pid]['audio_total'])) { |
|
|
|
|
$cacheData[$pid]['audio_total'] = 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ( |
|
|
|
|
!empty($item['filename']) && in_array($item['extension'], $supportedImageExts) |
|
|
|
|
) { |
|
|
|
|
$cacheData[$pid]['image_total'] ++; |
|
|
|
|
$imgNum ++; |
|
|
|
|
}else if ( |
|
|
|
|
!empty($item['filename']) && in_array($item['extension'], $supportedVideoExts) |
|
|
|
|
) { |
|
|
|
|
$cacheData[$pid]['video_total'] ++; |
|
|
|
|
$videoNum ++; |
|
|
|
|
}else if ( |
|
|
|
|
!empty($item['filename']) && in_array($item['extension'], $supportedAudioExts) |
|
|
|
|
) { |
|
|
|
|
$cacheData[$pid]['audio_total'] ++; |
|
|
|
|
$audioNum ++; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!empty($pid) && !empty($cacheData[$pid])) { |
|
|
|
|
if (!isset($cacheData[$pid]['image_total'])) { |
|
|
|
|
$cacheData[$pid]['image_total'] = 0; |
|
|
|
|
} |
|
|
|
|
if (!isset($cacheData[$pid]['video_total'])) { |
|
|
|
|
$cacheData[$pid]['video_total'] = 0; |
|
|
|
|
} |
|
|
|
|
if (!isset($cacheData[$pid]['audio_total'])) { |
|
|
|
|
$cacheData[$pid]['audio_total'] = 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$cacheData[$pid]['image_total'] += $imgNum; |
|
|
|
|
$cacheData[$pid]['video_total'] += $videoNum; |
|
|
|
|
$cacheData[$pid]['audio_total'] += $audioNum; |
|
|
|
|
} |
|
|
|
|
$cacheData[$dirId]['image_total'] = $imgNum; |
|
|
|
|
$cacheData[$dirId]['video_total'] = $videoNum; |
|
|
|
|
$cacheData[$dirId]['audio_total'] = $audioNum; |
|
|
|
|
echo "File total: {$dirId}: image {$imgNum}, video {$videoNum}, audio {$audioNum}\n"; |
|
|
|
|
|
|
|
|
|
return Common::setCache($cacheKey, $cacheData); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected function getAllFilesTotalInSubDirs() { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//汇总每个目录下图片、视频、音乐文件数量 |
|
|
|
|
/** |
|
|
|
|
* 数据格式: |
|
|
|
@ -477,7 +492,7 @@ eof;
@@ -477,7 +492,7 @@ eof;
|
|
|
|
|
|
|
|
|
|
$dirCounter = array(); |
|
|
|
|
foreach ($cacheData as $id => $item) { |
|
|
|
|
if ( !empty($item['directory']) && isset($item['image_total']) ) { |
|
|
|
|
if ( isset($item['image_total']) ) { |
|
|
|
|
$dirCounter[$id] = array( |
|
|
|
|
'image_total' => $item['image_total'], |
|
|
|
|
'video_total' => $item['video_total'], |
|
|
|
|