Compare commits

..

No commits in common. "8fcea9c84bb736489c10aecca443a3fdc8bb7076" and "359869984e464f3ede1a9e7ecd944cae5356d0dc" have entirely different histories.

5 changed files with 24 additions and 33 deletions

@ -1 +1 @@
Subproject commit e67b24b5f1035c9096e729437579794a7677bd3a
Subproject commit 390165edf85e26c53f2fd53353270ee2ad4c4a38

View File

@ -32,7 +32,7 @@ data Thread = Thread
, locked :: Maybe Int
, cyclical :: Maybe J.Cyclical
, last_modified :: Int
-- , board :: Text
, board :: Text
, files :: Maybe [J.File]
, resto :: Int
, unique_ips :: Maybe Int

View File

@ -23,7 +23,7 @@ data Post = Post
, cyclical :: Maybe J.Cyclical
, last_modified :: Int
, embed :: Maybe Text
-- , board :: Text
, board :: Text
, files :: Maybe [J.File]
, resto :: Int
, unique_ips :: Maybe Int

View File

@ -312,7 +312,7 @@ copyOrMoveFiles settings fgs (site, board, thread, _, path, attachment) = do
src :: FilePath
src = At.file_path path
thumb_src :: Maybe FilePath
thumb_src :: FilePath
thumb_src = At.thumbnail_path path
dest :: FilePath
@ -451,8 +451,8 @@ processFiles settings fgs tuples = do -- perfect just means that our posts have
, At.phash = phash
}
parseLegacyPaths :: Boards.Board -> JSONPosts.Post -> Maybe (At.Paths, At.Attachment)
parseLegacyPaths board post = do
parseLegacyPaths :: JSONPosts.Post -> Maybe (At.Paths, At.Attachment)
parseLegacyPaths post = do
tim <- JSONPosts.tim post
ext <- JSONPosts.ext post
filename <- JSONPosts.filename post
@ -460,12 +460,11 @@ processFiles settings fgs tuples = do -- perfect just means that our posts have
spoiler <- JSONPosts.fsize post
let
board_pathpart = T.pack $ Boards.pathpart board
file_path = (withPathPrefix "") </> (T.unpack $ board_pathpart <> "/src/" <> tim <> ext)
thumb_extension = "png"
thumbnail_path = (withPathPrefix "") </> (T.unpack $ board_pathpart <> "/thumb/" <> tim <> "." <> thumb_extension)
board = JSONPosts.board post
file_path = withPathPrefix $ board <> "/src/" <> tim <> ext
thumbnail_path = withPathPrefix $ board <> "/thumb/" <> tim <> ext
p = At.Paths file_path (Just thumbnail_path)
p = At.Paths file_path thumbnail_path
mime = getMimeType ext
@ -478,7 +477,7 @@ processFiles settings fgs tuples = do -- perfect just means that our posts have
, At.post_id = undefined
, At.resolution = undefined
, At.file_extension = Just $ T.drop 1 ext
, At.thumb_extension = Just $ thumb_extension
, At.thumb_extension = Just $ "png"
, At.original_filename = Just $ filename <> ext
, At.file_size_bytes = size
, At.board_filename = tim
@ -506,12 +505,12 @@ processFiles settings fgs tuples = do -- perfect just means that our posts have
, board
, thread
, q
, At.Paths (withPathPrefix $ JS.file_path x) (Just $ withPathPrefix $ JS.thumb_path x)
, At.Paths (withPathPrefix $ JS.file_path x) (withPathPrefix $ JS.thumb_path x)
, fileToAttachment i q x
)
) (zip [1..] files)
Nothing ->
case parseLegacyPaths board p of
case parseLegacyPaths p of
Nothing -> []
Just (paths, a) ->
let
@ -607,7 +606,7 @@ data FileGetters = FileGetters
, getJSONPosts :: Sites.Site -> String -> IO (Either String JSONPosts.PostWrapper)
, addPathPrefix :: String -> String
, attachmentPaths :: At.Paths -> IO (Maybe At.Paths)
, copyOrMove :: String -> (String, String) -> (Maybe String, String) -> IO ()
, copyOrMove :: String -> (String, String) -> (String, String) -> IO ()
}
@ -619,7 +618,7 @@ localFileGetters settings = FileGetters
, attachmentPaths = \p -> do
exists <- doesFileExist (At.file_path p)
if exists then return (Just p) else return Nothing
, copyOrMove = \common_dest (src, dest) (m_thumb_src, thumb_dest) -> do
, copyOrMove = \common_dest (src, dest) (thumb_src, thumb_dest) -> do
destination_exists <- doesFileExist dest
if not destination_exists
@ -632,14 +631,11 @@ localFileGetters settings = FileGetters
then putStrLn ("Copying " ++ src) >> copyFile src dest
else return ()
case m_thumb_src of
Nothing -> return ()
Just thumb_src -> do
thumb_exists <- doesFileExist thumb_src
thumb_exists <- doesFileExist thumb_src
if thumb_exists
then putStrLn ("Copying " ++ thumb_src) >> copyFile thumb_src thumb_dest
else return ()
if thumb_exists
then putStrLn ("Copying " ++ thumb_src) >> copyFile thumb_src thumb_dest
else return ()
else return ()
}

View File

@ -70,22 +70,17 @@ httpFileGetters settings = FileGetters
-- it downloads them into a temporary file and gets that path of that.
, attachmentPaths = \paths -> do
filepath <- Client.getFile (At.file_path paths)
m_thumbpath <- case At.thumbnail_path paths of
Nothing -> return Nothing
Just thumbpath -> Client.getFile thumbpath
thumbpath <- Client.getFile (At.thumbnail_path paths)
return $ filepath >>= \fp ->
case m_thumbpath of
Nothing -> return (At.Paths fp Nothing)
tp -> return (At.Paths fp tp)
thumbpath >>= \tp -> do
return (At.Paths fp tp)
, copyOrMove = \common_dest (src, dest) (m_thumb_src, thumb_dest) -> do
, copyOrMove = \common_dest (src, dest) (thumb_src, thumb_dest) -> do
putStrLn $ "Copy Or Move (Move) src: " ++ src ++ " dest: " ++ dest
createDirectoryIfMissing True common_dest
moveFile src dest
case m_thumb_src of
Nothing -> return ()
Just thumb_src -> moveFile thumb_src thumb_dest
moveFile thumb_src thumb_dest
}
httpGetJSON :: (FromJSON a) => Sites.Site -> String -> IO (Either String a)