From d5697d052e5154b909f379073a591ebf66eb3e22 Mon Sep 17 00:00:00 2001 From: Jon Eugster Date: Fri, 8 Dec 2023 00:58:17 +0100 Subject: [PATCH] images folder might not exist --- server/GameServer/Commands.lean | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/server/GameServer/Commands.lean b/server/GameServer/Commands.lean index 9cd98f18..a7fafc87 100644 --- a/server/GameServer/Commands.lean +++ b/server/GameServer/Commands.lean @@ -688,17 +688,18 @@ open IO.FS System FilePath in /-- Copies the folder `images/` to `.lake/gamedata/images/` -/ def copyImages : IO Unit := do let target : FilePath := ".lake" / "gamedata" - for file in ← walkDir "images" do - let outFile := target.join file - -- create the directories - if ← file.isDir then - createDirAll outFile - else - if let some parent := outFile.parent then - createDirAll parent - -- copy file - let content ← readBinFile file - writeBinFile outFile content + if ← FilePath.pathExists "images" then + for file in ← walkDir "images" do + let outFile := target.join file + -- create the directories + if ← file.isDir then + createDirAll outFile + else + if let some parent := outFile.parent then + createDirAll parent + -- copy file + let content ← readBinFile file + writeBinFile outFile content