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 () => {
|
||||
app.use(morgan('combined'));
|
||||
app.use(cors());
|
||||
app.use(express.json());
|
||||
app.use(express.json({ limit: '50mb' }));
|
||||
|
||||
try {
|
||||
const mode = process.env.MODE || 'fs';
|
||||
|
@ -9,6 +9,9 @@ const sha256 = (buffer: Buffer) => {
|
||||
.digest('hex');
|
||||
};
|
||||
|
||||
// normalize windows os path format
|
||||
const normalizePath = (path: string) => path.replace(/\\/g, '/');
|
||||
|
||||
export const entriesFromFiles = async (repoPath: string, files: string[]) => {
|
||||
return Promise.all(
|
||||
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));
|
||||
return {
|
||||
data: content.toString(),
|
||||
file: { path: file, id: sha256(content) },
|
||||
file: { path: normalizePath(file), id: sha256(content) },
|
||||
};
|
||||
} catch (e) {
|
||||
return { data: null, file: { path: file, id: null } };
|
||||
@ -34,7 +37,7 @@ export const readMediaFile = async (repoPath: string, file: string) => {
|
||||
id,
|
||||
content: buffer.toString(encoding),
|
||||
encoding,
|
||||
path: file,
|
||||
path: normalizePath(file),
|
||||
name: path.basename(file),
|
||||
};
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user