feat(core): core:update 기본을 코어 변경분만 적용(3-way skip)으로 전환
core:update Step 7 이 targets 전체를 무조건 재복사하고 orphan 을 삭제하여 사용자 .htaccess 커스텀 블록·_bundled 커스텀 확장이 소실되던 사고(공개 )를 차단한다. 백업(base)↔_pending(theirs) 3-way md5 비교로 코어가 실제 변경/추가한 파일만 산출해 적용하고, 코어 미변경 파일은 복사·권한·mtime 을 전부 스킵해 현재 디스크 상태(사용자 수정 포함)를 보존한다. 전체 덮어쓰기 + orphan 정리가 필요하면 --prune 으로 opt-in. 백업 부재(--no-backup) 시 base 가 없어 전체 덮어쓰기로 안전 회귀 + 안내를 출력한다. 기존 stale 정리 테스트는 새 기본(증분)에서 orphan 을 삭제하지 않으므로 prune 컨텍스트로 전환했고, 증분 3-way 판정·목록 적용·fallback 단위 테스트와 --prune 커맨드 표면 테스트를 추가했다. 번들 ja 언어팩은 코어 apply_mode 안내 키(g7-core-ja)와 함께, 같은 빌드에서 동기화된 관리자↔유저 크로스링크 라벨(board/ecommerce/admin_basic/basic)의 일본어 번역을 반영하고 각 패키지 버전·CHANGELOG 를 갱신했다.
This commit is contained in:
1 parent
efc8a7ae6b
commit
d0943d6cb6
26 files changed
+921
-29
No files matched your search
@@ -28,6 +28,7 @@ class CoreUpdateCommand extends Command
|
||||
protected $signature = 'core:update
|
||||
{--force : 버전 비교 없이 강제 업데이트}
|
||||
{--no-backup : 백업 생성 건너뛰기}
|
||||
{--prune : 코어가 제거한 파일 정리 + targets 전체 덮어쓰기(기존 방식). 미지정 시 코어가 실제 변경/추가한 파일만 적용하고 나머지는 보존}
|
||||
{--no-maintenance : 유지보수 모드 활성화 건너뛰기}
|
||||
{--local : 로컬 코드베이스를 업데이트 소스로 사용 (GitHub 스킵)}
|
||||
{--source= : 수동 업데이트용 소스 디렉토리 경로 (GitHub 다운로드 대신 지정 디렉토리 사용)}
|
||||
@@ -346,6 +347,12 @@ class CoreUpdateCommand extends Command
|
||||
//
|
||||
// `--no-backup` 모드면 backupPath 가 null 이므로 manifest 생성을 스킵 — 롤백
|
||||
// 자체가 불가능한 모드이므로 기존 동작 유지.
|
||||
// 증분 적용(3-way) 대상 목록. 백업 있음 + --prune 미지정 시에만 산출.
|
||||
// null 로 남으면(백업 부재 또는 --prune) applyUpdate 가 전체 덮어쓰기로 회귀.
|
||||
$applyList = null;
|
||||
$applyStats = null;
|
||||
$prune = (bool) $this->option('prune');
|
||||
|
||||
if ($backupPath !== null) {
|
||||
$bar->setMessage('신규 파일 manifest 생성 중...');
|
||||
$log('신규 파일 manifest 생성 시작');
|
||||
@@ -371,15 +378,51 @@ class CoreUpdateCommand extends Command
|
||||
'error' => $manifestError->getMessage(),
|
||||
]);
|
||||
}
|
||||
|
||||
// ── 증분 적용 대상 산출 (3-way) ──
|
||||
// --prune 이면 전체 덮어쓰기이므로 산출 자체를 스킵.
|
||||
if (! $prune) {
|
||||
try {
|
||||
$applyStats = CoreBackupHelper::computeApplyList(
|
||||
$backupPath,
|
||||
$pendingPath,
|
||||
(array) config('app.update.targets', []),
|
||||
(array) config('app.update.protected_paths', []),
|
||||
(array) config('app.update.excludes', []),
|
||||
);
|
||||
$applyList = $applyStats['apply'];
|
||||
$log(sprintf(
|
||||
'증분 적용 대상 산출 완료 (added=%d, changed=%d, total=%d)',
|
||||
$applyStats['added_count'],
|
||||
$applyStats['changed_count'],
|
||||
count($applyList),
|
||||
));
|
||||
} catch (\Throwable $applyError) {
|
||||
// 산출 실패 시 안전하게 전체 덮어쓰기로 회귀 (applyList=null 유지)
|
||||
$applyList = null;
|
||||
$applyStats = null;
|
||||
$log("증분 적용 대상 산출 실패 (전체 덮어쓰기로 회귀): {$applyError->getMessage()}");
|
||||
Log::warning('코어 업데이트: 증분 적용 대상 산출 실패', [
|
||||
'error' => $applyError->getMessage(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ── Step 7: 파일 적용 ──
|
||||
$bar->setMessage(__('settings.core_update.step_apply'));
|
||||
$bar->advance();
|
||||
$log('코어 파일 덮어쓰기 시작');
|
||||
|
||||
$service->applyUpdate($pendingPath, $onProgress);
|
||||
$log('코어 파일 덮어쓰기 완료');
|
||||
if ($prune) {
|
||||
$log('코어 파일 덮어쓰기 시작 (--prune: 전체 덮어쓰기 + orphan 정리)');
|
||||
} elseif ($applyList !== null) {
|
||||
$log(sprintf('코어 파일 적용 시작 (증분: 코어 변경분 %d건만 적용, 나머지 보존)', count($applyList)));
|
||||
} else {
|
||||
$log('코어 파일 덮어쓰기 시작 (백업 부재 — 전체 덮어쓰기로 회귀)');
|
||||
}
|
||||
|
||||
$service->applyUpdate($pendingPath, $onProgress, prune: $prune, applyList: $applyList);
|
||||
$log('코어 파일 적용 완료');
|
||||
|
||||
// ── Step 8: vendor 디렉토리 복사 (_pending → 운영) ──
|
||||
if ($composerSkipped) {
|
||||
@@ -503,6 +546,9 @@ class CoreUpdateCommand extends Command
|
||||
$this->info("그누보드7 코어가 {$toVersion} 버전으로 업데이트되었습니다!");
|
||||
$this->newLine();
|
||||
|
||||
// ── 파일 적용 방식 요약 (부수의무: 설명의무) ──
|
||||
$this->summarizeApplyMode($prune, $applyList, $applyStats);
|
||||
|
||||
// _bundled 확장 일괄 업데이트 프롬프트 (번들에 신버전이 있을 때만 표시).
|
||||
//
|
||||
// 주의: Step 11 restoreOwnership 이후에 실행되므로, 프롬프트 내 실제
|
||||
@@ -1068,6 +1114,41 @@ class CoreUpdateCommand extends Command
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 파일 적용 방식(증분/prune/fallback)과 통계를 사용자에게 요약 출력합니다.
|
||||
*
|
||||
* @param bool $prune --prune 지정 여부
|
||||
* @param array<int, string>|null $applyList 증분 적용 대상 목록 (null 이면 전체 덮어쓰기)
|
||||
* @param array{apply:array<int,string>, added_count:int, changed_count:int, has_symlink:bool}|null $applyStats computeApplyList 산출 통계
|
||||
*/
|
||||
private function summarizeApplyMode(bool $prune, ?array $applyList, ?array $applyStats): void
|
||||
{
|
||||
if ($prune) {
|
||||
$this->line(__('settings.core_update.apply_mode_prune'));
|
||||
$this->newLine();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ($applyList === null) {
|
||||
// 백업 부재 또는 산출 실패 → 전체 덮어쓰기로 회귀
|
||||
$this->warn(__('settings.core_update.apply_mode_fallback'));
|
||||
$this->newLine();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// 증분 모드
|
||||
$added = $applyStats['added_count'] ?? 0;
|
||||
$changed = $applyStats['changed_count'] ?? 0;
|
||||
$this->line(__('settings.core_update.apply_mode_incremental', [
|
||||
'added' => $added,
|
||||
'changed' => $changed,
|
||||
]));
|
||||
$this->line(__('settings.core_update.apply_mode_incremental_prune_hint'));
|
||||
$this->newLine();
|
||||
}
|
||||
|
||||
/**
|
||||
* 업데이트 로그를 파일로 저장합니다.
|
||||
*
|
||||
|
||||
@@ -336,6 +336,176 @@ class CoreBackupHelper
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 코어(신 버전)가 실제로 추가·변경한 파일 목록(적용 대상)을 3-way 비교로 산출합니다.
|
||||
*
|
||||
* `core:update` 기본(증분) 모드에서 `applyUpdate()` 가 참조하는 "적용 대상 집합"을
|
||||
* 만든다. 코어가 건드리지 않은 파일(base == theirs)은 목록에서 제외되어, 활성
|
||||
* 디렉토리에 남은 현재 상태(사용자 수정 포함 가능)를 그대로 보존한다.
|
||||
*
|
||||
* 3-way 판정:
|
||||
* - base = 구버전 원본 = 백업 스냅샷 (`$backupPath/$target`)
|
||||
* - theirs = 신 버전 = _pending 소스 (`$sourcePath/$target`)
|
||||
* - 규칙:
|
||||
* · base 없음 (theirs 에만 존재) → added (신규 파일 — 적용)
|
||||
* · base 있고 size 또는 md5 다름 → changed (코어가 변경 — 적용)
|
||||
* · base 있고 size·md5 동일 → 제외 (코어 미변경 — 스킵/보존)
|
||||
*
|
||||
* 성능: size 가 다르면 md5 를 계산하지 않는다(즉시 changed). size 가 같을 때만
|
||||
* `md5_file`. mtime 은 비교하지 않는다 — `_pending` 은 방금 추출되어 mtime 이
|
||||
* 전부 추출 시각이므로 항상 "다름"으로 오판한다.
|
||||
*
|
||||
* symlink 는 목록에서 제외한다 — 링크 자체는 `copyDirectory` 의 별도 링크 처리
|
||||
* 경로가 담당하며, 증분 모드에서도 항상 재생성되어야 한다(target 추적 없이 동일
|
||||
* 링크). 따라서 반환값 `is_partial` 이 true 여도 링크는 정상 반영된다.
|
||||
*
|
||||
* `writeNewFilesManifest()` 와 동일한 순회 구조·가드(`excludes`/`protectedPaths`)를
|
||||
* 재사용한다. 두 산출을 각각 별도 순회하지만, 반환값은 in-memory 로 즉시 소비되어
|
||||
* 파일화 비용이 없다(롤백용 `_new_files_manifest.json` 은 별도).
|
||||
*
|
||||
* @param string $backupPath 백업 디렉토리 경로 (= base, 활성 사전 스냅샷)
|
||||
* @param string $sourcePath 소스 디렉토리 경로 (= theirs, _pending 신 버전)
|
||||
* @param array $targets 처리할 target 경로 목록 (`app.update.targets`)
|
||||
* @param array $protectedPaths 보호 경로 목록 (목록에서 제외)
|
||||
* @param array $excludes 제외 패턴 목록 (예: ['node_modules', '.git'])
|
||||
* @return array{apply:array<int,string>, added_count:int, changed_count:int, has_symlink:bool}
|
||||
* apply = 적용 대상 상대경로 목록(정렬됨, 슬래시 정규화)
|
||||
*/
|
||||
public static function computeApplyList(
|
||||
string $backupPath,
|
||||
string $sourcePath,
|
||||
array $targets,
|
||||
array $protectedPaths,
|
||||
array $excludes,
|
||||
): array {
|
||||
$added = [];
|
||||
$changed = [];
|
||||
$hasSymlink = false;
|
||||
|
||||
$protectedSet = self::normalizeProtectedSet($protectedPaths);
|
||||
$excludeSet = array_values(array_filter(array_map('trim', $excludes)));
|
||||
|
||||
foreach ($targets as $target) {
|
||||
$target = trim($target);
|
||||
if ($target === '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (self::isWithinProtectedPath($target, $protectedSet)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$sourceTargetPath = $sourcePath.DIRECTORY_SEPARATOR.$target;
|
||||
if (! file_exists($sourceTargetPath)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 단일 파일 target
|
||||
if (is_file($sourceTargetPath) && ! is_link($sourceTargetPath)) {
|
||||
$rel = self::normalizeRelative($target);
|
||||
$backupFilePath = $backupPath.DIRECTORY_SEPARATOR.$target;
|
||||
self::classifyForApply($rel, $sourceTargetPath, $backupFilePath, $added, $changed);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (is_link($sourceTargetPath)) {
|
||||
$hasSymlink = true;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (! is_dir($sourceTargetPath)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 디렉토리 target — 재귀 비교
|
||||
$iterator = new RecursiveIteratorIterator(
|
||||
new RecursiveDirectoryIterator($sourceTargetPath, FilesystemIterator::SKIP_DOTS),
|
||||
RecursiveIteratorIterator::SELF_FIRST,
|
||||
);
|
||||
|
||||
foreach ($iterator as $item) {
|
||||
/** @var SplFileInfo $item */
|
||||
$absolute = $item->getPathname();
|
||||
$relative = self::normalizeRelative($target.'/'.ltrim(substr($absolute, strlen($sourceTargetPath)), DIRECTORY_SEPARATOR.'/'));
|
||||
|
||||
if (self::matchesExcludes($relative, $excludeSet)) {
|
||||
continue;
|
||||
}
|
||||
if (self::isWithinProtectedPath($relative, $protectedSet)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// symlink 는 목록 제외 — 링크 처리 경로가 별도 담당
|
||||
if ($item->isLink()) {
|
||||
$hasSymlink = true;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
// 디렉토리 자체는 목록에 담지 않는다 — 파일 단위 적용이 디렉토리를
|
||||
// 필요 시 생성한다(copyDirectory 가 대상 디렉토리를 ensure).
|
||||
if (! $item->isFile()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$backupItemPath = $backupPath.DIRECTORY_SEPARATOR.str_replace('/', DIRECTORY_SEPARATOR, $relative);
|
||||
self::classifyForApply($relative, $absolute, $backupItemPath, $added, $changed);
|
||||
}
|
||||
}
|
||||
|
||||
$apply = array_values(array_unique(array_merge($added, $changed)));
|
||||
sort($apply, SORT_STRING);
|
||||
|
||||
return [
|
||||
'apply' => $apply,
|
||||
'added_count' => count($added),
|
||||
'changed_count' => count($changed),
|
||||
'has_symlink' => $hasSymlink,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 3-way 판정으로 파일 하나를 added/changed 로 분류하거나 제외합니다.
|
||||
*
|
||||
* base(백업) 부재 → added, size 다름 또는 md5 다름 → changed, 동일 → 제외.
|
||||
*
|
||||
* @param string $relative 슬래시 정규화된 상대 경로 (목록 등재값)
|
||||
* @param string $theirsAbsolute 신 버전(_pending) 파일 절대 경로
|
||||
* @param string $baseAbsolute 백업(base) 파일 절대 경로
|
||||
* @param array<int,string> $added added 누적 배열 (참조)
|
||||
* @param array<int,string> $changed changed 누적 배열 (참조)
|
||||
*/
|
||||
private static function classifyForApply(
|
||||
string $relative,
|
||||
string $theirsAbsolute,
|
||||
string $baseAbsolute,
|
||||
array &$added,
|
||||
array &$changed,
|
||||
): void {
|
||||
if (! file_exists($baseAbsolute) || is_dir($baseAbsolute)) {
|
||||
$added[] = $relative;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// size 선필터 — 다르면 md5 생략하고 즉시 changed
|
||||
$theirsSize = @filesize($theirsAbsolute);
|
||||
$baseSize = @filesize($baseAbsolute);
|
||||
if ($theirsSize !== $baseSize) {
|
||||
$changed[] = $relative;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// size 동일 → 내용 비교
|
||||
if (@md5_file($theirsAbsolute) !== @md5_file($baseAbsolute)) {
|
||||
$changed[] = $relative;
|
||||
}
|
||||
// 동일하면 제외 (코어 미변경 — 스킵)
|
||||
}
|
||||
|
||||
/**
|
||||
* 백업 디렉토리의 manifest 를 로드해 활성 디렉토리에서 신 버전 신규 파일을 정리합니다.
|
||||
*
|
||||
|
||||
@@ -32,8 +32,13 @@ class FilePermissionHelper
|
||||
* @param string $relativePath 현재 상대 경로 (내부 재귀용)
|
||||
* @param bool $removeOrphans 소스에 없는 대상 파일/디렉토리 삭제 여부
|
||||
* @param bool $preserveTopLevelOrphans 최상위 한 레벨의 orphan 보존 여부
|
||||
* @param array<string, bool>|null $applyList 적용 대상 파일 상대경로 화이트리스트
|
||||
* (이 디렉토리 루트 기준, `'sub/file.txt' => true` 형태의 lookup 맵). null 이면
|
||||
* 전체 파일 복사(기존 동작). 지정 시 이 맵에 없는 파일은 복사를 스킵한다 — 코어
|
||||
* 업데이트 증분 모드에서 "코어가 변경하지 않은 파일"을 건드리지 않기 위함. symlink
|
||||
* 는 이 필터의 영향을 받지 않고 항상 재생성된다(링크는 목록 산출 대상이 아님).
|
||||
*/
|
||||
public static function copyDirectory(string $source, string $destination, ?\Closure $onProgress = null, array $excludes = [], string $relativePath = '', bool $removeOrphans = false, bool $preserveTopLevelOrphans = false): void
|
||||
public static function copyDirectory(string $source, string $destination, ?\Closure $onProgress = null, array $excludes = [], string $relativePath = '', bool $removeOrphans = false, bool $preserveTopLevelOrphans = false, ?array $applyList = null): void
|
||||
{
|
||||
if (! File::isDirectory($destination)) {
|
||||
// 신규 디렉토리: 부모 디렉토리의 퍼미션/소유권 상속
|
||||
@@ -76,8 +81,13 @@ class FilePermissionHelper
|
||||
|
||||
if ($item->isDir()) {
|
||||
// preserveTopLevelOrphans 는 최상위 한 레벨 한정 — 자식 재귀에는 항상 false 전달.
|
||||
static::copyDirectory($item->getPathname(), $destPath, $onProgress, $excludes, $itemRelativePath, $removeOrphans, preserveTopLevelOrphans: false);
|
||||
static::copyDirectory($item->getPathname(), $destPath, $onProgress, $excludes, $itemRelativePath, $removeOrphans, preserveTopLevelOrphans: false, applyList: $applyList);
|
||||
} else {
|
||||
// 증분 모드(applyList 지정): 화이트리스트에 없는 파일은 스킵 —
|
||||
// 코어가 변경하지 않은 파일의 현재 디스크 상태(사용자 수정 포함)를 보존.
|
||||
if ($applyList !== null && ! isset($applyList[$itemRelativePath])) {
|
||||
continue;
|
||||
}
|
||||
static::copyFile($item->getPathname(), $destPath);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -885,7 +885,16 @@ class CoreUpdateService
|
||||
}
|
||||
|
||||
/**
|
||||
* 코어 업데이트 대상 파일만 선택적으로 덮어씁니다.
|
||||
* 코어 업데이트 대상 파일을 덮어씁니다.
|
||||
*
|
||||
* 기본(증분) 모드 — `$applyList` 가 주어지고 `$prune === false`:
|
||||
* - 코어(신 버전)가 실제로 추가·변경한 파일만 적용한다(3-way 판정 산출물).
|
||||
* - 코어가 건드리지 않은 파일은 복사·chmod·chown·mtime 갱신을 전부 스킵하여 현재
|
||||
* 디스크 상태(사용자 수정 포함 가능)를 그대로 보존한다.
|
||||
* - orphan(소스에 없는 대상 파일) 삭제를 하지 않는다 — 사용자가 추가한 신규 파일 보존.
|
||||
*
|
||||
* prune 모드 — `$prune === true` 또는 `$applyList === null`(백업 부재 fallback):
|
||||
* - targets 전체를 무조건 덮어쓰고, 소스에 없는 orphan 을 삭제한다(기존 동작).
|
||||
*
|
||||
* 주의: ExtensionPendingHelper::copyToActive()는 PHP copy()를 사용하여
|
||||
* 파일 퍼미션/소유자를 보존하지 않으므로, 코어 업데이트에서는 사용하지 않습니다.
|
||||
@@ -893,12 +902,29 @@ class CoreUpdateService
|
||||
*
|
||||
* @param string $sourcePath 소스 경로 (_pending 내)
|
||||
* @param \Closure|null $onProgress 진행 콜백
|
||||
* @param bool $prune true 면 전체 덮어쓰기 + orphan 삭제(기존 동작), false 면 증분 적용
|
||||
* @param array<int, string>|null $applyList 적용 대상 상대경로 목록(target 접두사 포함).
|
||||
* `CoreBackupHelper::computeApplyList()` 산출물. null 이면 증분 불가로 판단해 전체 덮어쓰기.
|
||||
*/
|
||||
public function applyUpdate(string $sourcePath, ?\Closure $onProgress = null): void
|
||||
public function applyUpdate(string $sourcePath, ?\Closure $onProgress = null, bool $prune = false, ?array $applyList = null): void
|
||||
{
|
||||
$targets = config('app.update.targets', []);
|
||||
$excludes = config('app.update.excludes', []);
|
||||
|
||||
// 증분 모드 여부: prune 이 아니고 적용 목록이 주어진 경우에만 증분 적용.
|
||||
// applyList 가 null 이면(백업 부재 등) 안전을 위해 전체 덮어쓰기로 회귀한다.
|
||||
$incremental = ! $prune && $applyList !== null;
|
||||
|
||||
// 증분 모드에서 각 target 하위 파일을 O(1) 로 조회하기 위한 lookup 맵.
|
||||
// computeApplyList 는 target 접두사를 포함한 상대경로(예: 'public/.htaccess')를
|
||||
// 반환하므로, 그대로 정규화 키로 담는다.
|
||||
$applySet = [];
|
||||
if ($incremental) {
|
||||
foreach ($applyList as $rel) {
|
||||
$applySet[$this->normalizeRelativePath((string) $rel)] = true;
|
||||
}
|
||||
}
|
||||
|
||||
$applied = [];
|
||||
|
||||
foreach ($targets as $target) {
|
||||
@@ -909,21 +935,45 @@ class CoreUpdateService
|
||||
continue;
|
||||
}
|
||||
|
||||
$normalizedTarget = $this->normalizeRelativePath($target);
|
||||
|
||||
$onProgress?->__invoke('apply', $target);
|
||||
|
||||
if (File::isDirectory($src)) {
|
||||
// 증분 모드: 이 target 하위의 적용 대상만 추린 뒤, target 접두사를 벗겨
|
||||
// copyDirectory 의 내부 상대경로($itemRelativePath)와 직접 매칭되는
|
||||
// 화이트리스트 맵을 만든다.
|
||||
$targetApplyList = null;
|
||||
if ($incremental) {
|
||||
$targetApplyList = $this->buildTargetApplyList($applySet, $normalizedTarget);
|
||||
}
|
||||
|
||||
// `{domain}/_bundled` 타깃은 최상위 한 레벨의 orphan 을 보존한다 — 사용자가
|
||||
// `_bundled/` 바로 아래에 직접 만든 커스텀 확장 디렉토리/파일이 코어 업데이트
|
||||
// 소스(번들 확장만 포함)에 없다는 이유로 삭제되던 결함 차단.
|
||||
// 번들 확장 디렉토리 *내부* stale 정리는 그대로 유지된다.
|
||||
$preserveTopLevelOrphans = str_ends_with($this->normalizeRelativePath($target), '_bundled');
|
||||
FilePermissionHelper::copyDirectory($src, $dest, $onProgress, $excludes, removeOrphans: true, preserveTopLevelOrphans: $preserveTopLevelOrphans);
|
||||
// 번들 확장 디렉토리 *내부* stale 정리는 prune 모드에서만 수행된다.
|
||||
$preserveTopLevelOrphans = str_ends_with($normalizedTarget, '_bundled');
|
||||
FilePermissionHelper::copyDirectory(
|
||||
$src,
|
||||
$dest,
|
||||
$onProgress,
|
||||
$excludes,
|
||||
removeOrphans: $prune,
|
||||
preserveTopLevelOrphans: $preserveTopLevelOrphans,
|
||||
applyList: $targetApplyList,
|
||||
);
|
||||
} else {
|
||||
// 단일 파일 target — 증분 모드에서는 적용 목록에 있을 때만 복사.
|
||||
if ($incremental && ! isset($applySet[$normalizedTarget])) {
|
||||
$applied[$normalizedTarget] = true;
|
||||
|
||||
continue;
|
||||
}
|
||||
File::ensureDirectoryExists(dirname($dest));
|
||||
FilePermissionHelper::copyFile($src, $dest);
|
||||
}
|
||||
|
||||
$applied[$this->normalizeRelativePath($target)] = true;
|
||||
$applied[$normalizedTarget] = true;
|
||||
}
|
||||
|
||||
// 자동 발견 폴백 — 부모 프로세스(구버전) 의 stale `app.update.targets` 가
|
||||
@@ -1005,6 +1055,31 @@ class CoreUpdateService
|
||||
return trim(str_replace(['\\', '/'], '/', $path), '/');
|
||||
}
|
||||
|
||||
/**
|
||||
* 전체 적용 집합에서 특정 target 하위 항목만 추려, target 접두사를 제거한
|
||||
* `copyDirectory` 내부 상대경로 화이트리스트 맵을 만듭니다.
|
||||
*
|
||||
* `computeApplyList` 는 target 접두사를 포함한 경로(예: `public/.htaccess`)를 담지만,
|
||||
* `copyDirectory` 는 target 루트 기준 상대경로(`.htaccess`)로 항목을 순회하므로 접두사를
|
||||
* 벗겨야 매칭된다.
|
||||
*
|
||||
* @param array<string, bool> $applySet 전체 적용 대상 정규화 경로 lookup 맵
|
||||
* @param string $normalizedTarget 정규화된 target 경로 (예: `public`)
|
||||
* @return array<string, bool> target 내부 상대경로 화이트리스트 (빈 맵일 수 있음 → 전부 스킵)
|
||||
*/
|
||||
private function buildTargetApplyList(array $applySet, string $normalizedTarget): array
|
||||
{
|
||||
$prefix = $normalizedTarget.'/';
|
||||
$out = [];
|
||||
foreach ($applySet as $rel => $_) {
|
||||
if (str_starts_with((string) $rel, $prefix)) {
|
||||
$out[substr((string) $rel, strlen($prefix))] = true;
|
||||
}
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* 정규화된 path 가 이미 처리된 상위/하위 path 와 관계가 있는지 검사합니다.
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user