Skip to content

Commit

Permalink
fix: ignore mkdir if exists (#24)
Browse files Browse the repository at this point in the history
closes #23
  • Loading branch information
fengmk2 authored Feb 13, 2023
1 parent edb7f80 commit 92f3c33
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions app/middleware/static.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
'use strict';

const assert = require('assert');
const { mkdirSync } = require('fs');
const { mkdirSync, existsSync } = require('fs');
const range = require('koa-range');
const compose = require('koa-compose');
const staticCache = require('koa-static-cache');
Expand Down Expand Up @@ -46,7 +44,9 @@ module.exports = (options, app) => {
}

// ensure directory exists
mkdirSync(newOptions.dir, { recursive: true });
if (!existsSync(newOptions.dir)) {
mkdirSync(newOptions.dir, { recursive: true });
}

app.loggers.coreLogger.info('[egg-static] starting static serve %s -> %s', newOptions.prefix, newOptions.dir);

Expand Down

0 comments on commit 92f3c33

Please sign in to comment.