diff options
| author | Roman Smrž <roman.smrz@seznam.cz> | 2025-11-05 21:14:01 +0100 |
|---|---|---|
| committer | Roman Smrž <roman.smrz@seznam.cz> | 2025-11-05 21:14:01 +0100 |
| commit | ebe120fcfffc6d4d8ca261cfef7699eac7fd94fe (patch) | |
| tree | 0e907f05a3c434abe8c2a13d94f8980e01f7785d | |
| parent | 164c2dc41dcdbda4df2f71cdced84f7831a049d0 (diff) | |
Store artifact work path along with data
| -rw-r--r-- | src/Command/Extract.hs | 10 | ||||
| -rw-r--r-- | src/Job.hs | 8 |
2 files changed, 8 insertions, 10 deletions
diff --git a/src/Command/Extract.hs b/src/Command/Extract.hs index b21c63c..6828029 100644 --- a/src/Command/Extract.hs +++ b/src/Command/Extract.hs @@ -93,15 +93,11 @@ cmdExtract (ExtractCommand ExtractOptions {..} ExtractArguments {..}) = do True -> return () False -> tfail $ "artifact ‘" <> aname <> "’ of job ‘" <> textJobId jid <> "’ not found" - afile <- liftIO (listDirectory adir) >>= \case - [ file ] -> return file - [] -> tfail $ "artifact ‘" <> aname <> "’ of job ‘" <> textJobId jid <> "’ not found" - _:_:_ -> tfail $ "unexpected files in ‘" <> T.pack adir <> "’" - - let tpath | isdir = extractDestination </> afile + wpath <- liftIO $ readFile (adir </> "path") + let tpath | isdir = extractDestination </> takeFileName wpath | otherwise = extractDestination when (not extractForce) $ do liftIO (doesPathExist tpath) >>= \case True -> tfail $ "destination ‘" <> T.pack tpath <> "’ already exists" False -> return () - liftIO $ copyRecursiveForce (adir </> afile) tpath + liftIO $ copyRecursiveForce (adir </> "data") tpath @@ -329,8 +329,8 @@ runJob job uses checkoutPath jdir = do | fromIntegral n == -sigINT -> throwError JobCancelled | otherwise -> throwError JobFailed - let adir = jdir </> "artifacts" artifacts <- forM (jobArtifacts job) $ \( name@(ArtifactName tname), pathPattern ) -> do + let adir = jdir </> "artifacts" </> T.unpack tname path <- liftIO (globDir1 pathPattern checkoutPath) >>= \case [ path ] -> return path found -> do @@ -338,13 +338,15 @@ runJob job uses checkoutPath jdir = do (if null found then "no file" else "multiple files") <> " found matching pattern ‘" <> decompile pathPattern <> "’ for artifact ‘" <> T.unpack tname <> "’" throwError JobFailed - let target = adir </> T.unpack tname </> takeFileName path + let target = adir </> "data" + workPath = makeRelative checkoutPath path liftIO $ do createDirectoryIfMissing True $ takeDirectory target copyRecursiveForce path target + writeFile (adir </> "path") workPath return $ ArtifactOutput { aoutName = name - , aoutWorkPath = makeRelative checkoutPath path + , aoutWorkPath = workPath , aoutStorePath = target } |