applyCreatedFileToRemote :: FilePath -> Map Path RemoteFile -> Path -> ApiAction (Change, RemoteFile)
applyCreatedFileToRemote syncDir remoteFiles (Path relativeFilePath) = do
    let parentDirPath = addTrailingPathSeparator . takeDirectory $ relativeFilePath
    let absoluteFilePath = syncDir </> relativeFilePath
    let parentDirMaybe = Map.lookup (Path parentDirPath) remoteFiles
    case parentDirMaybe of
        Just parentDir -> do
            remoteFile <- upload parentDir absoluteFilePath
            return (Created (File (Path relativeFilePath) (modifiedTime (getFile remoteFile))), remoteFile)
        Nothing -> error $ "no parent dir: " ++ parentDirPath
applyCreatedFileToRemote :: FilePath -> Map Path RemoteFile -> Path -> ApiAction (Change, RemoteFile)
applyCreatedFileToRemote syncDir remoteFiles (Path relativeFilePath) = do
    let parentDirPath = addTrailingPathSeparator . takeDirectory $ relativeFilePath
    let absoluteFilePath = syncDir </> relativeFilePath
    let parentDirMaybe = Map.lookup (Path parentDirPath) remoteFiles
    case parentDirMaybe of
        Just parentDir -> do
            remoteFile <- upload parentDir absoluteFilePath
            return (Created (File (Path relativeFilePath) (modifiedTime (getFile remoteFile))), remoteFile)
        Nothing -> error $ "no parent dir: " ++ parentDirPath
applyCreatedFileToRemote syncDir remoteFiles (Path relativeFilePath) = do
    let parentDirPath = addTrailingPathSeparator . takeDirectory $ relativeFilePath
    let absoluteFilePath = syncDir </> relativeFilePath
    let parentDirMaybe = Map.lookup (Path parentDirPath) remoteFiles
    case parentDirMaybe of
        Just parentDir -> do
            remoteFile <- upload parentDir absoluteFilePath
            return (Created (File (Path relativeFilePath) (modifiedTime (getFile remoteFile))), remoteFile)
        Nothing -> error $ "no parent dir: " ++ parentDirPath