Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
X
xpub-epmc
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package Registry
Container Registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Literature-services
public-projects
xpub-epmc
Commits
2c61d655
Commit
2c61d655
authored
3 years ago
by
Yogmatee Roochun
Browse files
Options
Downloads
Patches
Plain Diff
#1168 : Ensured that file renaming occurs on FTP, even for files that cannot be extracted
parent
ef33c433
No related branches found
Branches containing commit
No related tags found
Tags containing commit
3 merge requests
!380
Pipeline changes
,
!379
Build step added for the master branch
,
!378
k8s release
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
server/ftp-integration/api.js
+8
-9
8 additions, 9 deletions
server/ftp-integration/api.js
server/utils/ebi-ftp.js
+3
-2
3 additions, 2 deletions
server/utils/ebi-ftp.js
with
11 additions
and
11 deletions
server/ftp-integration/api.js
+
8
−
9
View file @
2c61d655
...
...
@@ -75,8 +75,6 @@ const tidyUp = async (filePath, tmpPath, manId, isError) => {
}
if
(
isError
)
{
logger
.
info
(
`Error in Bulk import process for
${
filePath
}
`
)
logger
.
info
(
`File has been moved to
${
updatedFilepath
}
`
)
// await updateFTP(updatedFilepath, submitter)
}
else
{
logger
.
info
(
`Finished Bulk import process for
${
filePath
}
as manuscript
${
manId
}
.`
,
...
...
@@ -86,7 +84,7 @@ const tidyUp = async (filePath, tmpPath, manId, isError) => {
})
})
}
catch
(
e
)
{
logger
.
error
(
'
Error while tidying up after another error!
'
)
logger
.
error
(
`An error has happened while processing file
${
fileName
}
`
)
}
return
Journal
.
knex
().
destroy
()
}
...
...
@@ -181,7 +179,7 @@ const runProcess = async (packagePath, submitter) => {
logger
.
info
(
`Starting Bulk Import Process for
${
packagePath
}
`
)
packageName
=
path
.
basename
(
packagePath
)
tmpPath
=
await
createTempDir
()
const
tmpPathExt
=
await
extractFiles
(
packagePath
,
tmpPath
)
const
tmpPathExt
=
await
extractFiles
(
packagePath
,
tmpPath
,
submitter
)
// rename file - append .start suffix
suffixedFilePath
=
await
fileUtils
.
renameFileSuffix
(
packagePath
)
const
parsedInfo
=
await
parseManifest
(
tmpPathExt
,
packageName
)
...
...
@@ -222,15 +220,16 @@ const runProcess = async (packagePath, submitter) => {
}
}
const
extractFiles
=
(
source
,
dest
)
=>
const
extractFiles
=
(
source
,
dest
,
submitter
)
=>
new
Promise
((
resolve
,
reject
)
=>
{
const
cmd
=
`tar vzxf
${
source
}
-C
${
dest
}
--xform='s#^.+/##x'`
// the xform removes all directories
exec
(
cmd
,
async
err
=>
{
if
(
err
)
{
logger
.
error
(
'
Error extracting FTP bulk upload files
'
)
// node couldn't execute the command
await
tidyUp
(
source
,
dest
,
''
,
true
)
logger
.
error
(
`
${
source
}
moved to Error folder`
)
logger
.
error
(
`Error extracting FTP bulk upload file:
${
source
}
`
)
const
updatedFilepath
=
await
tidyUp
(
source
,
dest
,
''
,
true
)
logger
.
info
(
`File
${
source
}
has been moved to
${
updatedFilepath
}
`
)
await
updateFTP
(
updatedFilepath
,
submitter
)
reject
(
err
)
}
resolve
(
dest
)
...
...
@@ -855,6 +854,6 @@ const updateFTP = async (updatedFilepath, submitter) => {
processedFilename
,
)
}
catch
(
err
)
{
logger
.
error
(
'
Error with updating FTP
'
)
logger
.
error
(
'
Error with updating FTP
'
,
err
)
}
}
This diff is collapsed.
Click to expand it.
server/utils/ebi-ftp.js
+
3
−
2
View file @
2c61d655
...
...
@@ -134,8 +134,9 @@ module.exports.renameBulkFtpPackage = async function renameBulkFtpPackage(
close
(
ftp
)
reject
(
err
)
}
// get array of tar.gz files only
const
ftpPackageName
=
await
checkBulkFtpPackage
(
processedFilename
)
// get array of tar.gz files only
const
ftpFile
=
list
.
filter
(
file
=>
file
.
name
===
ftpPackageName
&&
file
.
type
===
'
-
'
,
)[
0
]
...
...
@@ -181,7 +182,7 @@ module.exports.renameBulkFtpPackage = async function renameBulkFtpPackage(
function
checkBulkFtpPackage
(
packageName
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
const
file_ext
=
new
RegExp
(
/
((\.
start
\.
loaded
\.
mid-EMS
\d
+
)
|
(\.
start
\.
ERROR
))\.\d{4}
-
\d{2}
-
\d{2}
_
\d{2}
:
\d{2}
:
\d{2}
$/i
,
/
((\.
start
\.
loaded
\.
mid-EMS
\d
+
)
|
(\.
start
\.
ERROR
)
|
(\.
ERROR
)
)\.\d{4}
-
\d{2}
-
\d{2}
_
\d{2}
:
\d{2}
:
\d{2}
$/i
,
)
if
(
file_ext
.
test
(
packageName
))
resolve
(
packageName
.
split
(
file_ext
)[
0
])
else
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
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