mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-24 23:48:13 -05:00
Reverted zip's root file copying fix
refs https://github.com/TryGhost/Toolbox/issues/523
- The reverted fix did not take into account the "original path" of the
files would be truncated. This path has to be full relative to the root
of the zip to later be used during importer url substitution logic.
- This reverts commit 831a76505c
.
This commit is contained in:
parent
dda1d7cf26
commit
c487b12518
4 changed files with 6 additions and 21 deletions
|
@ -301,14 +301,7 @@ class ImportManager {
|
|||
const baseDir = this.getBaseDirectory(zipDirectory);
|
||||
|
||||
for (const handler of this.handlers) {
|
||||
let files = [];
|
||||
if (handler.directories?.length > 0) {
|
||||
for (const dir of handler.directories) {
|
||||
files.push(...this.getFilesFromZip(handler, path.join(zipDirectory, (baseDir || ''), dir)));
|
||||
}
|
||||
} else {
|
||||
files.push(...this.getFilesFromZip(handler, zipDirectory));
|
||||
}
|
||||
const files = this.getFilesFromZip(handler, zipDirectory);
|
||||
|
||||
debug('handler', handler.type, files);
|
||||
|
||||
|
|
|
@ -228,7 +228,7 @@ describe('Importer', function () {
|
|||
extractSpy.calledOnce.should.be.true();
|
||||
validSpy.calledOnce.should.be.true();
|
||||
baseDirSpy.calledOnce.should.be.true();
|
||||
getFileSpy.callCount.should.eql(9);
|
||||
getFileSpy.callCount.should.eql(6);
|
||||
jsonSpy.calledOnce.should.be.true();
|
||||
imageSpy.called.should.be.false();
|
||||
mdSpy.called.should.be.false();
|
||||
|
|
|
@ -52,24 +52,16 @@ describe('ImporterContentFileHandler', function () {
|
|||
});
|
||||
|
||||
const files = [{
|
||||
name: 'content/media/video-in-content-media.mp4'
|
||||
}, {
|
||||
name: 'media/video-in-media.mp4'
|
||||
name: 'content/media/1.mp4'
|
||||
}];
|
||||
const subDir = 'blog';
|
||||
|
||||
await contentFileImporter.loadFile(files, subDir);
|
||||
|
||||
assert.equal(files.length, 2);
|
||||
assert.equal(files[0].name, 'video-in-content-media.mp4');
|
||||
assert.equal(files[0].originalPath, 'content/media/video-in-content-media.mp4');
|
||||
assert.equal(files[0].name, '1.mp4');
|
||||
assert.equal(files[0].originalPath, 'content/media/1.mp4');
|
||||
assert.equal(files[0].targetDir, '/var/www/ghost/content/media');
|
||||
assert.equal(files[0].newPath, '//blog/content/media/video-in-content-media.mp4');
|
||||
|
||||
assert.equal(files[1].name, 'video-in-media.mp4');
|
||||
assert.equal(files[1].originalPath, 'media/video-in-media.mp4');
|
||||
assert.equal(files[1].targetDir, '/var/www/ghost/content/media');
|
||||
assert.equal(files[1].newPath, '//blog/content/media/video-in-media.mp4');
|
||||
assert.equal(files[0].newPath, '//blog/content/media/1.mp4');
|
||||
});
|
||||
|
||||
it('loads files and decorates them with newPath with NO subdirectory', async function () {
|
||||
|
|
Loading…
Add table
Reference in a new issue