-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
71 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,4 +13,5 @@ tmp | |
.tmp | ||
settings.json | ||
docker/runtime | ||
docker/log | ||
docker/log | ||
archiv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,4 +20,6 @@ public/s | |
public-docker | ||
org.* | ||
settings.json | ||
docker-compose.yml | ||
docker-compose.yml | ||
docker/runtime | ||
archiv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,5 @@ public-docker | |
tmp | ||
temp | ||
data | ||
docker | ||
docker | ||
archiv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import fs from 'fs' | ||
import {sendError} from 'h3' | ||
import { ARCHIV_PATH } from '~~/base/Constants'; | ||
import { findFile } from '../findFilePath'; | ||
|
||
export default defineEventHandler( async (event) => { | ||
const query = getQuery(event); | ||
if (query.name) { | ||
return { path: findFile(query.name, ARCHIV_PATH) } | ||
} else | ||
sendError(event, createError("No path or filename provided")) | ||
return { path:"" } | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import fs from 'fs' | ||
import path from 'path' | ||
|
||
export function findFile(name: string, path: string) : string { | ||
const dirs = [path] | ||
while (dirs.length>0) { | ||
const currentDir = dirs.pop() | ||
const items = fs.readdirSync(currentDir); | ||
for (const item of items) { | ||
if (!(fs.lstatSync(`${currentDir}/${item}`)).isDirectory()) { | ||
if (item===name) | ||
return `${currentDir}/${item}` | ||
} else | ||
dirs.push(`${currentDir}/${item}`) | ||
} | ||
} | ||
return "" | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { describe, expect, it } from "vitest"; | ||
import { findFile } from "../../server/findFilePath"; | ||
|
||
describe("DetailValidation", async () => { | ||
it.skip("Epmty dir returns empty string", () => { | ||
const actual = findFile("a", "tests/testdata/empty") | ||
expect(actual).toBe(""); | ||
}) | ||
it("File in sub dir returns its path", () => { | ||
const actual = findFile("b.txt", "tests/testdata") | ||
expect(actual).toBe("tests/testdata/dir1/b.txt"); | ||
}) | ||
it("File in deeply nested sub dir returns its path", () => { | ||
const actual = findFile("c.txt", "tests/testdata") | ||
expect(actual).toBe("tests/testdata/dir2/dir21/dir211/c.txt"); | ||
}) | ||
it("File not in deeply nested sub dir empty string", () => { | ||
const actual = findFile("ct", "tests/testdata") | ||
expect(actual).toBe(""); | ||
}) | ||
}) |