smoonb 0.0.68 → 0.0.69
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -149,7 +149,7 @@ module.exports = async ({ backupPath, targetProject }) => {
|
|
|
149
149
|
const bucketDirs = [];
|
|
150
150
|
|
|
151
151
|
// Verificar se a pasta raiz é o Project ID (antigo ou novo)
|
|
152
|
-
// Se for, as subpastas são os buckets reais
|
|
152
|
+
// Se for, as subpastas são os buckets reais - NUNCA tratar a pasta raiz como bucket
|
|
153
153
|
let rootDir = null;
|
|
154
154
|
if (extractedContents.length === 1) {
|
|
155
155
|
const firstItem = extractedContents[0];
|
|
@@ -158,35 +158,19 @@ module.exports = async ({ backupPath, targetProject }) => {
|
|
|
158
158
|
|
|
159
159
|
if (firstItemStats.isDirectory()) {
|
|
160
160
|
// Verificar se o nome da pasta raiz corresponde ao Project ID antigo OU novo
|
|
161
|
-
// Isso pode acontecer se a pasta raiz original era o Project ID antigo
|
|
162
|
-
// e pode ou não ter sido renomeada para o Project ID novo pela função replaceProjectIdInExtractedFiles
|
|
163
161
|
const isProjectId =
|
|
164
162
|
(sourceProjectId && firstItem === sourceProjectId) ||
|
|
165
163
|
(firstItem === targetProject.targetProjectId);
|
|
166
164
|
|
|
167
165
|
if (isProjectId) {
|
|
168
|
-
//
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
try {
|
|
173
|
-
const stats = fs.statSync(itemPath);
|
|
174
|
-
return stats.isDirectory();
|
|
175
|
-
} catch {
|
|
176
|
-
return false;
|
|
177
|
-
}
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
if (hasSubDirs) {
|
|
181
|
-
// A pasta raiz é um wrapper do Project ID - buscar buckets nas subpastas
|
|
182
|
-
rootDir = firstItem;
|
|
183
|
-
console.log(chalk.white(` - Detectada pasta raiz com Project ID: ${firstItem}`));
|
|
184
|
-
console.log(chalk.white(` - Buscando buckets nas subpastas...`));
|
|
185
|
-
}
|
|
166
|
+
// A pasta raiz é um wrapper do Project ID - SEMPRE buscar buckets nas subpastas
|
|
167
|
+
rootDir = firstItem;
|
|
168
|
+
console.log(chalk.white(` - Detectada pasta raiz com Project ID: ${firstItem}`));
|
|
169
|
+
console.log(chalk.white(` - Buscando buckets nas subpastas...`));
|
|
186
170
|
}
|
|
187
171
|
}
|
|
188
172
|
}
|
|
189
|
-
|
|
173
|
+
|
|
190
174
|
if (rootDir) {
|
|
191
175
|
// Estrutura com Project ID: project-id/bucket-name/...
|
|
192
176
|
// Listar subpastas dentro da pasta do Project ID - essas são os buckets reais
|
|
@@ -203,6 +187,13 @@ module.exports = async ({ backupPath, targetProject }) => {
|
|
|
203
187
|
});
|
|
204
188
|
}
|
|
205
189
|
}
|
|
190
|
+
|
|
191
|
+
// Se não encontrou buckets nas subpastas, avisar e retornar erro
|
|
192
|
+
if (bucketDirs.length === 0) {
|
|
193
|
+
console.log(chalk.red(` ❌ Erro: Nenhum bucket encontrado nas subpastas de ${rootDir}`));
|
|
194
|
+
console.log(chalk.red(` ❌ A pasta raiz é um Project ID e não deve ser tratada como bucket`));
|
|
195
|
+
return { success: false, buckets_count: 0 };
|
|
196
|
+
}
|
|
206
197
|
} else {
|
|
207
198
|
// Estrutura direta: bucket-name/...
|
|
208
199
|
// As pastas raiz são os buckets
|