Skip to content
Open
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
3 changes: 2 additions & 1 deletion lib/file.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,8 @@ class File extends EventEmitter {
}
}

let url = `https://mega.nz/${this.directory ? 'folder' : 'file'}/${this.downloadId}`
const downloadId = Array.isArray(this.downloadId) ? this.downloadId[1] : this.downloadId
let url = `https://mega.nz/${this.directory ? 'folder' : 'file'}/${downloadId}`
if (!options.noKey && this.key) url += `#${e64(this.key)}`
if (!options.noKey && this.loadedFile) {
// TODO: check if the loaded file is, in fact, a folder
Expand Down
2 changes: 2 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
"ava": "^6.1.2",
"buffer": "^6.0.3",
"core-js": "^3.36.1",
"cross-spawn": "^7.0.6",
"esbuild": "^0.25.0",
"esbuild-plugin-alias": "^0.2.1",
"events": "^3.3.0",
Expand Down
8 changes: 3 additions & 5 deletions test/helpers/test-runner.mjs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// This script handles test preparation, running in Node and Deno then cleanup
import alias from 'esbuild-plugin-alias'
import { fileURLToPath } from 'node:url'
import cp from 'node:child_process'
import fs from 'node:fs/promises'
import megamock from 'mega-mock'
import crypto from 'node:crypto'
import spawn from 'cross-spawn'
import esbuild from 'esbuild'
import tmp from 'tmp-promise'
import path from 'node:path'
Expand Down Expand Up @@ -131,14 +131,13 @@ let wasFailed = false
// Run tests
if (testedPlatform === 'node') {
await new Promise(resolve => {
const subprocess = cp.spawn('npx', [
const subprocess = spawn('npx', [
'ava',
'--',
path.join(buildDir, '*.js'),
...extraArguments
], {
stdio: 'inherit',
shell: os.platform() === 'win32',
env: {
...process.env,
MEGA_MOCK_URL: gateway
Expand All @@ -160,7 +159,7 @@ if (testedPlatform === 'node') {
})
} else {
await new Promise(resolve => {
const subprocess = cp.spawn('deno', [
const subprocess = spawn('deno', [
'test',
'--no-check',
'--allow-env=MEGA_MOCK_URL',
Expand All @@ -169,7 +168,6 @@ if (testedPlatform === 'node') {
], {
cwd: buildDir,
stdio: 'inherit',
shell: os.platform() === 'win32',
env: {
...process.env,
MEGA_MOCK_URL: gateway
Expand Down
12 changes: 12 additions & 0 deletions test/storage.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,18 @@ test.serial('Should upload files in folders in shared folders', t => {
})
})

// See issue #240
// SKIPPED: depends on fixing mega-mock shared file key handling
test.serial.skip('.link() should work in files in shared folders', async t => {
const folder = File.fromURL('https://mega.nz/folder/AAAAAAAG#AAAAAAAAAAAAAAAAAAAAAA')
folder.api = storage.api
await folder.loadAttributes()

const file = folder.children[0]
const link = await file.link()
t.is(link, 'https://mega.nz/folder/AAAAAAAG#AAAAAAAAAAAAAAAAAAAAAA')
})

// TODO implement test for download files shared in folders
// Depends on fixing mega-mock shared file key handling

Expand Down