Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
gbs-downloader
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
PrivateStorage
gbs-downloader
Commits
648ae13e
Commit
648ae13e
authored
May 31, 2023
by
Shae Erisson
Browse files
Options
Downloads
Patches
Plain Diff
fix imports after refactoring
parent
af168f0f
No related branches found
No related tags found
1 merge request
!4
Cleanup immutable factoring
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/Tahoe/Download.hs
+3
-12
3 additions, 12 deletions
src/Tahoe/Download.hs
src/Tahoe/Download/Internal/Client.hs
+10
-0
10 additions, 0 deletions
src/Tahoe/Download/Internal/Client.hs
src/Tahoe/Download/Internal/Immutable.hs
+7
-10
7 additions, 10 deletions
src/Tahoe/Download/Internal/Immutable.hs
with
20 additions
and
22 deletions
src/Tahoe/Download.hs
+
3
−
12
View file @
648ae13e
...
...
@@ -11,34 +11,25 @@ module Tahoe.Download (
announcementToStorageServer
,
)
where
import
Control.Exception
(
Exception
(
displayException
),
SomeException
,
throwIO
,
try
)
import
Control.Exception
(
Exception
(
displayException
),
SomeException
,
try
)
import
Control.Monad.IO.Class
(
MonadIO
(
liftIO
))
import
Data.Bifunctor
(
Bifunctor
(
first
,
second
))
import
Data.Binary
(
Word16
,
decodeOrFail
)
import
qualified
Data.ByteString
as
B
import
Data.ByteString.Base32
(
encodeBase32Unpadded
)
import
qualified
Data.ByteString.Base64
as
Base64
import
qualified
Data.ByteString.Lazy
as
LB
import
Data.Either
(
partitionEithers
,
rights
)
import
Data.List
(
foldl'
)
import
qualified
Data.Map.Strict
as
Map
import
qualified
Data.Set
as
Set
import
qualified
Data.Text
as
T
import
Data.Text.Encoding
(
encodeUtf8
)
import
Network.Connection
(
TLSSettings
(
TLSSettingsSimple
))
import
Network.HTTP.Client
(
Manager
,
ManagerSettings
(
managerModifyRequest
),
Request
(
requestHeaders
))
import
Network.HTTP.Client.TLS
(
mkManagerSettings
,
newTlsManagerWith
)
import
Network.URI
(
URI
(
..
),
URIAuth
(
..
))
import
Servant.Client
(
Scheme
(
Https
),
mkClientEnv
,
runClientM
)
import
Servant.Client.Core
(
BaseUrl
(
BaseUrl
,
baseUrlHost
,
baseUrlPath
,
baseUrlPort
,
baseUrlScheme
))
import
Tahoe.Announcement
(
StorageServerAnnouncement
,
greatBlackSwampURIs
)
import
qualified
Tahoe.CHK
import
Tahoe.CHK.Capability
(
Reader
(
..
),
Verifier
(
..
))
import
qualified
Tahoe.CHK.Encrypt
import
Tahoe.CHK.Server
(
StorageServer
(
..
),
StorageServerID
)
import
Tahoe.CHK.Types
(
ShareNum
,
StorageIndex
)
import
Tahoe
LAFS.Storage.API
(
CBORSet
(
..
),
ShareNumber
(
ShareNumber
))
import
Tahoe
LAFS.Storage.Client
(
getImmutableShareNumbers
,
read
Immutable
Share
)
import
Tahoe
.Download.Internal.Client
import
Tahoe
.Download.Internal.
Immutable
import
Text.Read
(
readMaybe
)
print'
::
MonadIO
m
=>
String
->
m
()
...
...
This diff is collapsed.
Click to expand it.
src/Tahoe/Download/Internal/Client.hs
+
10
−
0
View file @
648ae13e
module
Tahoe.Download.Internal.Client
where
import
Control.Monad.IO.Class
import
qualified
Data.ByteString
as
B
import
qualified
Data.ByteString.Base64
as
Base64
import
qualified
Data.Text
as
T
import
Data.Text.Encoding
import
Network.Connection
import
Network.HTTP.Client
import
Network.HTTP.Client.TLS
import
Servant.Client
-- | Make an HTTPS URL.
https
::
String
->
Int
->
BaseUrl
https
host
port
=
...
...
This diff is collapsed.
Click to expand it.
src/Tahoe/Download/Internal/Immutable.hs
+
7
−
10
View file @
648ae13e
module
Tahoe.Download.Internal.Immutable
where
import
Control.Exception
(
SomeException
(
SomeException
))
import
Control.Exception
import
Data.ByteString.Base32
import
qualified
Data.Set
as
Set
import
qualified
Data.Text
as
T
import
Network.HTTP.Client
(
Manager
)
import
Tahoe.CHK.Server
(
StorageServer
(
StorageServer
))
import
Servant.Client
import
Tahoe.CHK.Server
(
StorageServer
(
..
))
import
Tahoe.Download.Internal.Client
import
TahoeLAFS.Storage.API
(
CBORSet
(
CBORSet
),
ShareNumber
(
ShareNumber
))
import
TahoeLAFS.Storage.Client
{- | Create a StorageServer that will speak Great Black Swamp using the given
manager to the server at the given host/port.
...
...
@@ -24,27 +28,20 @@ wrapGreatBlackSwamp manager host realPort =
storageServerRead
storageIndex
shareNum
=
do
let
clientm
=
readImmutableShare
(
toBase32
storageIndex
)
(
ShareNumber
$
fromIntegral
shareNum
)
Nothing
print'
"Going to read from a server"
res
<-
runClientM
clientm
env
print'
"Did it"
case
res
of
Left
err
->
do
print'
"Going to throw a damn IO error"
throwIO
err
Right
bs
->
pure
bs
storageServerGetBuckets
storageIndex
=
do
let
clientm
=
getImmutableShareNumbers
(
toBase32
storageIndex
)
print'
"Going to get share numbers"
r
<-
try
$
runClientM
clientm
env
case
r
of
Left
(
err
::
SomeException
)
->
do
print'
$
"A PROBLEM ARISES "
<>
show
err
Left
(
_
::
SomeException
)
->
do
pure
mempty
Right
res
->
do
print'
"Got the share numbers"
case
res
of
Left
err
->
do
print'
"Going to throw another IO error!!"
throwIO
err
Right
(
CBORSet
s
)
->
pure
$
Set
.
map
(
\
(
ShareNumber
i
)
->
fromIntegral
i
)
s
-- XXX fromIntegral aaaaaaaa!!
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment