Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

revert #4600 #4623

Merged
merged 1 commit into from
May 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/poor-seals-turn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@verdaccio/tarball': patch
'@verdaccio/store': patch
---

revert #4600
4 changes: 1 addition & 3 deletions packages/core/tarball/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@
"@verdaccio/url": "workspace:12.0.0-next-7.14",
"@verdaccio/utils": "workspace:7.0.0-next-7.14",
"debug": "4.3.4",
"gunzip-maybe": "^1.4.2",
"lodash": "4.17.21",
"tar-stream": "^3.1.7"
"lodash": "4.17.21"
},
"devDependencies": {
"@verdaccio/types": "workspace:12.0.0-next.2",
Expand Down
34 changes: 0 additions & 34 deletions packages/core/tarball/src/getTarballDetails.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/core/tarball/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@ export {
convertDistVersionToLocalTarballsUrl,
} from './convertDistRemoteToLocalTarballUrls';
export { extractTarballFromUrl, getLocalRegistryTarballUri } from './getLocalRegistryTarballUri';
export { TarballDetails, getTarballDetails } from './getTarballDetails';

export { RequestOptions };
Binary file removed packages/core/tarball/tests/assets/tarball.tar
Binary file not shown.
Binary file removed packages/core/tarball/tests/assets/tarball.tgz
Binary file not shown.
37 changes: 0 additions & 37 deletions packages/core/tarball/tests/getTarballDetails.spec.ts

This file was deleted.

35 changes: 3 additions & 32 deletions packages/store/src/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,9 @@ import {
} from '@verdaccio/proxy';
import Search from '@verdaccio/search';
import {
TarballDetails,
convertDistRemoteToLocalTarballUrls,
convertDistVersionToLocalTarballsUrl,
extractTarballFromUrl,
getTarballDetails,
} from '@verdaccio/tarball';
import {
AbbreviatedManifest,
Expand Down Expand Up @@ -1046,8 +1044,6 @@ class Storage {
// at this point document is either created or existed before
const [firstAttachmentKey] = Object.keys(_attachments);
const buffer = this.getBufferManifest(body._attachments[firstAttachmentKey].data as string);
const readable = Readable.from(buffer);
const tarballStats = await this.getTarballStats(versions[versionToPublish], readable);

try {
// we check if package exist already locally
Expand Down Expand Up @@ -1086,7 +1082,7 @@ class Storage {
_.isNil(manifest.readme) === false ? String(manifest.readme) : '';
}
// addVersion will move the readme from the the published version to the root level
await this.addVersion(name, versionToPublish, versions[versionToPublish], null, tarballStats);
await this.addVersion(name, versionToPublish, versions[versionToPublish], null);
} catch (err: any) {
logger.error({ err: err.message }, 'updated version has failed: @{err}');
debug('error on create a version for %o with error %o', name, err.message);
Expand Down Expand Up @@ -1114,6 +1110,7 @@ class Storage {

// 3. upload the tarball to the storage
try {
const readable = Readable.from(buffer);
await this.uploadTarball(name, basename(firstAttachmentKey), readable, {
signal: options.signal,
});
Expand Down Expand Up @@ -1286,8 +1283,7 @@ class Storage {
name: string,
version: string,
metadata: Version,
tag: StringValue,
tarballStats: TarballDetails
tag: StringValue
): Promise<void> {
debug(`add version %s package for %s`, version, name);
await this.updatePackage(name, async (data: Manifest): Promise<Manifest> => {
Expand All @@ -1299,12 +1295,6 @@ class Storage {
metadata.contributors = normalizeContributors(metadata.contributors as Author[]);
debug('%s` contributors normalized', name);

// Update tarball stats
if (metadata.dist) {
metadata.dist.fileCount = tarballStats.fileCount;
metadata.dist.unpackedSize = tarballStats.unpackedSize;
}

// if uploaded tarball has a different shasum, it's very likely that we
// have some kind of error
if (validatioUtils.isObject(metadata.dist) && _.isString(metadata.dist.tarball)) {
Expand Down Expand Up @@ -1915,25 +1905,6 @@ class Storage {
return cacheManifest;
}
}

private async getTarballStats(version: Version, readable: Readable): Promise<TarballDetails> {
if (
version.dist == undefined ||
version.dist?.fileCount == undefined ||
version.dist?.unpackedSize == undefined
) {
debug('tarball stats not found, calculating');
try {
return await getTarballDetails(readable);
} catch (err: any) {
logger.error({ err: err.message }, 'getting tarball details has failed: @{err}');
throw err;
}
} else {
debug('tarball stats found');
return { fileCount: version.dist.fileCount, unpackedSize: version.dist.unpackedSize };
}
}
}

export { Storage };
2 changes: 0 additions & 2 deletions packages/store/test/storage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,12 +262,10 @@ describe('storage', () => {
expect(manifestVersion._id).toEqual(`${pkgName}@1.0.1`);
expect(manifestVersion.description).toEqual('package generated');
expect(manifestVersion.dist).toEqual({
fileCount: 4,
integrity:
'sha512-6gHiERpiDgtb3hjqpQH5/i7zRmvYi9pmCjQf2ZMy3QEa9wVk9RgdZaPWUt7ZOnWUPFjcr9cmE6dUBf+XoPoH4g==',
shasum: '2c03764f651a9f016ca0b7620421457b619151b9',
tarball: 'http://localhost:5555/upstream/-/upstream-1.0.1.tgz',
unpackedSize: 543,
});

expect(manifestVersion.contributors).toEqual([]);
Expand Down
Loading
Loading