@@ -311,15 +311,24 @@ private def fetchFile (project : System.FilePath) (root : String) (file : System
311311 let json ← Json.parse json |> IO.ofExcept
312312 fromXrefJson root json |> IO.ofExcept
313313
314+ private def defaultConfigFile (project : System.FilePath) : System.FilePath := project / "verso-sources.json"
315+
316+ /--
317+ Returns `true` if the user has specified a configuration file, or if they haven't and the default file exists.
318+ -/
319+ private def hasConfig (project : System.FilePath) (configFile : Option System.FilePath) : IO Bool := do
320+ if configFile.isSome then return true
321+ else defaultConfigFile project |>.pathExists
322+
314323private def getConfig (project : System.FilePath) (configFile : Option System.FilePath) : IO Config := do
315- let configFile : System.FilePath :=
316- if let some f := configFile then f
317- else project / "verso-sources.json"
318- let configJson ← IO.FS.readFile configFile
319- let configJson ← Json.parse configJson |> IO.ofExcept
320- match Config.fromJson? configJson with
321- | .error e => throw <| IO.userError s! "Error reading { configFile} : { e} "
322- | .ok v => pure v
324+ let configFile : System.FilePath :=
325+ if let some f := configFile then f
326+ else defaultConfigFile project
327+ let configJson ← IO.FS.readFile configFile
328+ let configJson ← Json.parse configJson |> IO.ofExcept
329+ match Config.fromJson? configJson with
330+ | .error e => throw <| IO.userError s! "Error reading { configFile} : { e} "
331+ | .ok v => pure v
323332
324333/--
325334Information about a remote document
@@ -411,10 +420,14 @@ def updateRemotes (manual : Bool) (configFile : Option System.FilePath) (logVerb
411420 if let some f := configFile then
412421 logVerbose s! "Config override is { f} ."
413422 let config ←
414- try
415- getConfig project configFile
416- catch e =>
417- logVerbose s! "Didn't load remote data config. No remote data to be used. Error: { e} "
423+ if (← hasConfig project configFile) then
424+ try
425+ getConfig project configFile
426+ catch e =>
427+ logVerbose s! "Didn't load remote data config. No remote data to be used. Error: { e} "
428+ return {}
429+ else
430+ logVerbose s! "No remote data configuration specified, and the default file { defaultConfigFile "." } does not exist."
418431 return {}
419432
420433 logVerbose s! "Creating remote data cache directory { config.outputDir} "
0 commit comments