Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
haskell-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
195
Issues
195
List
Board
Labels
Milestones
Merge Requests
12
Merge Requests
12
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
haskell-gargantext
Commits
5f1195fd
Commit
5f1195fd
authored
Apr 15, 2024
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/312-dev-zip-file-last-modification-time-fix' into testing
parents
8de56ef9
71bc8cf8
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
22 additions
and
7 deletions
+22
-7
update-project-dependencies
bin/update-project-dependencies
+1
-1
cabal.project
cabal.project
+1
-1
Export.hs
src/Gargantext/API/Node/Document/Export.hs
+9
-1
Types.hs
src/Gargantext/API/Node/Document/Export/Types.hs
+5
-4
Zip.hs
src/Gargantext/Utils/Zip.hs
+6
-0
No files found.
bin/update-project-dependencies
View file @
5f1195fd
...
...
@@ -18,7 +18,7 @@ fi
# with the `sha256sum` result calculated on the `cabal.project` and
# `cabal.project.freeze`. This ensures the files stay deterministic so that CI
# cache can kick in.
expected_cabal_project_hash
=
"
96be39a29bab66851278db07974dc3c61e7f807aefc3a3e9d50a9eb269706ef0
"
expected_cabal_project_hash
=
"
7142cc1299cafe14f07273c3437409a862f7d931cff778a634312a450543c07b
"
expected_cabal_project_freeze_hash
=
"a88c2d091ee6223b64fb5dd38e71ab8379710a2aa716d2467f318789e4d75589"
cabal
--store-dir
=
$STORE_DIR
v2-build
--dry-run
...
...
cabal.project
View file @
5f1195fd
src/Gargantext/API/Node/Document/Export.hs
View file @
5f1195fd
...
...
@@ -16,6 +16,7 @@ import Data.ByteString.Lazy.Char8 qualified as BSC
import
Data.Csv
(
encodeDefaultOrderedByName
)
import
Data.Text
qualified
as
T
import
Data.Text.Encoding
qualified
as
TE
import
Data.Time.Clock.System
(
getSystemTime
,
systemSeconds
)
import
Data.Version
(
showVersion
)
import
Gargantext.API.Node.Document.Export.Types
import
Gargantext.API.Prelude
(
GargNoServer
,
GargServer
)
...
...
@@ -28,6 +29,7 @@ import Gargantext.Database.Schema.Node (NodePoly(..), node_user_id)
import
Gargantext.Prelude
import
Paths_gargantext
qualified
as
PG
-- cabal magic build module
import
Servant
(
addHeader
,
(
:<|>
)((
:<|>
)),
Header
,
Headers
(
getResponse
)
)
import
Data.Time.LocalTime
(
getCurrentTimeZone
,
TimeZone
(
timeZoneMinutes
))
api
::
NodeId
-- ^ The ID of the target user
...
...
@@ -79,8 +81,14 @@ getDocumentsJSONZip :: NodeId
->
GargNoServer
(
Headers
'[
H
eader
"Content-Disposition"
T
.
Text
]
DocumentExportZIP
)
-- [Document]
getDocumentsJSONZip
userNodeId
pId
=
do
dJSON
<-
getDocumentsJSON
userNodeId
pId
systime
<-
liftBase
getSystemTime
tz
<-
liftBase
getCurrentTimeZone
let
dexp
=
getResponse
dJSON
let
dexpz
=
DocumentExportZIP
{
_dez_dexp
=
dexp
,
_dez_doc_id
=
pId
}
let
dexpz
=
DocumentExportZIP
{
_dez_dexp
=
dexp
,
_dez_doc_id
=
pId
-- see https://github.com/jgm/zip-archive/commit/efe4423a9a2b1dc2a4d413917a933828d3f8dc0f
,
_dez_last_modified
=
fromIntegral
(
systemSeconds
systime
)
+
fromIntegral
(
timeZoneMinutes
tz
*
60
)
}
pure
$
addHeader
(
T
.
concat
[
"attachment; filename="
,
dezFileName
dexpz
,
".zip"
])
dexpz
...
...
src/Gargantext/API/Node/Document/Export/Types.hs
View file @
5f1195fd
...
...
@@ -25,7 +25,7 @@ import Gargantext.Database.Admin.Types.Hyperdata.Document ( HyperdataDocument(..
import
Gargantext.Database.Admin.Types.Node
(
DocId
)
import
Gargantext.Database.Schema.Node
(
NodePoly
(
..
))
import
Gargantext.Utils.Servant
(
ZIP
)
import
Gargantext.Utils.Zip
(
zipContentsPure
)
import
Gargantext.Utils.Zip
(
zipContentsPure
WithLastModified
)
import
Protolude
import
Servant
((
:>
),
(
:<|>
),
Get
,
Header
,
Headers
(
..
),
JSON
,
MimeRender
(
..
),
PlainText
,
Summary
)
...
...
@@ -39,7 +39,8 @@ data DocumentExport =
-- | This is to represent a zipped document export. We want to have doc_id in zipped file name.
data
DocumentExportZIP
=
DocumentExportZIP
{
_dez_dexp
::
DocumentExport
,
_dez_doc_id
::
DocId
}
deriving
(
Generic
)
,
_dez_doc_id
::
DocId
,
_dez_last_modified
::
Integer
}
deriving
(
Generic
)
data
Document
=
...
...
@@ -125,4 +126,4 @@ dezFileName (DocumentExportZIP { .. }) = "GarganText_DocsList-" <> show _dez_doc
instance
MimeRender
ZIP
DocumentExportZIP
where
mimeRender
_
dexpz
@
(
DocumentExportZIP
{
..
})
=
zipContentsPure
(
T
.
unpack
$
dezFileName
dexpz
)
(
encode
_dez_dexp
)
zipContentsPure
WithLastModified
(
T
.
unpack
$
dezFileName
dexpz
)
(
encode
_dez_dexp
)
_dez_last_modified
src/Gargantext/Utils/Zip.hs
View file @
5f1195fd
...
...
@@ -50,3 +50,9 @@ zipContentsPure :: FilePath -> BSC.ByteString -> BSC.ByteString
zipContentsPure
fpath
bscContents
=
ZArch
.
fromArchive
(
ZArch
.
addEntryToArchive
e
ZArch
.
emptyArchive
)
where
e
=
ZArch
.
toEntry
fpath
0
bscContents
zipContentsPureWithLastModified
::
FilePath
->
BSC
.
ByteString
->
Integer
->
BSC
.
ByteString
zipContentsPureWithLastModified
fpath
bscContents
lastModified
=
ZArch
.
fromArchive
(
ZArch
.
addEntryToArchive
e
ZArch
.
emptyArchive
)
where
e
=
ZArch
.
toEntry
fpath
lastModified
bscContents
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment