Fix: proxy fs on windows (#3229)
This commit is contained in:
parent
a399310513
commit
4b8c941da1
@ -11,7 +11,7 @@ const port = process.env.PORT || 8081;
|
|||||||
(async () => {
|
(async () => {
|
||||||
app.use(morgan('combined'));
|
app.use(morgan('combined'));
|
||||||
app.use(cors());
|
app.use(cors());
|
||||||
app.use(express.json());
|
app.use(express.json({ limit: '50mb' }));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const mode = process.env.MODE || 'fs';
|
const mode = process.env.MODE || 'fs';
|
||||||
|
@ -9,6 +9,9 @@ const sha256 = (buffer: Buffer) => {
|
|||||||
.digest('hex');
|
.digest('hex');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// normalize windows os path format
|
||||||
|
const normalizePath = (path: string) => path.replace(/\\/g, '/');
|
||||||
|
|
||||||
export const entriesFromFiles = async (repoPath: string, files: string[]) => {
|
export const entriesFromFiles = async (repoPath: string, files: string[]) => {
|
||||||
return Promise.all(
|
return Promise.all(
|
||||||
files.map(async file => {
|
files.map(async file => {
|
||||||
@ -16,7 +19,7 @@ export const entriesFromFiles = async (repoPath: string, files: string[]) => {
|
|||||||
const content = await fs.readFile(path.join(repoPath, file));
|
const content = await fs.readFile(path.join(repoPath, file));
|
||||||
return {
|
return {
|
||||||
data: content.toString(),
|
data: content.toString(),
|
||||||
file: { path: file, id: sha256(content) },
|
file: { path: normalizePath(file), id: sha256(content) },
|
||||||
};
|
};
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return { data: null, file: { path: file, id: null } };
|
return { data: null, file: { path: file, id: null } };
|
||||||
@ -34,7 +37,7 @@ export const readMediaFile = async (repoPath: string, file: string) => {
|
|||||||
id,
|
id,
|
||||||
content: buffer.toString(encoding),
|
content: buffer.toString(encoding),
|
||||||
encoding,
|
encoding,
|
||||||
path: file,
|
path: normalizePath(file),
|
||||||
name: path.basename(file),
|
name: path.basename(file),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user