Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
texjs-web
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
David Mehren
texjs-web
Commits
b28ce20c
Verified
Commit
b28ce20c
authored
7 years ago
by
Shane Kilkelly
Committed by
David Mehren
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Cleaner import of errors
parent
30b409f8
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/coffee/Features/LinkedFiles/ProjectOutputFileAgent.coffee
+13
-8
13 additions, 8 deletions
...coffee/Features/LinkedFiles/ProjectOutputFileAgent.coffee
with
13 additions
and
8 deletions
app/coffee/Features/LinkedFiles/ProjectOutputFileAgent.coffee
+
13
−
8
View file @
b28ce20c
...
...
@@ -5,7 +5,12 @@ CompileManager = require '../Compile/CompileManager'
ClsiManager
=
require
'../Compile/ClsiManager'
ProjectFileAgent
=
require
'./ProjectFileAgent'
_
=
require
"underscore"
LinkedFilesErrors
=
require
'./LinkedFilesErrors'
{
BadDataError
,
AccessDeniedError
,
BadEntityTypeError
,
OutputFileFetchFailedError
}
=
require
'./LinkedFilesErrors'
LinkedFilesHandler
=
require
'./LinkedFilesHandler'
logger
=
require
'logger-sharelatex'
...
...
@@ -15,7 +20,7 @@ module.exports = ProjectOutputFileAgent = {
_prepare
:
(
project_id
,
linkedFileData
,
user_id
,
callback
=
(
err
,
linkedFileData
)
->
)
->
@
_checkAuth
project_id
,
linkedFileData
,
user_id
,
(
err
,
allowed
)
=>
return
callback
(
err
)
if
err
?
return
callback
(
new
LinkedFilesErrors
.
AccessDeniedError
())
if
!
allowed
return
callback
(
new
AccessDeniedError
())
if
!
allowed
@
_decorateLinkedFileData
linkedFileData
,
(
err
,
newLinkedFileData
)
=>
return
callback
(
err
)
if
err
?
if
!
@
_validate
(
newLinkedFileData
)
...
...
@@ -24,7 +29,7 @@ module.exports = ProjectOutputFileAgent = {
createLinkedFile
:
(
project_id
,
linkedFileData
,
name
,
parent_folder_id
,
user_id
,
callback
)
->
if
!
@
_canCreate
(
linkedFileData
)
return
callback
(
new
LinkedFilesErrors
.
AccessDeniedError
())
return
callback
(
new
AccessDeniedError
())
linkedFileData
=
@
_sanitizeData
(
linkedFileData
)
@
_prepare
project_id
,
linkedFileData
,
user_id
,
(
err
,
linkedFileData
)
=>
return
callback
(
err
)
if
err
?
...
...
@@ -44,7 +49,7 @@ module.exports = ProjectOutputFileAgent = {
return
callback
(
err
)
if
err
?
callback
(
null
,
file
.
_id
)
# Created
else
err
=
new
LinkedFilesErrors
.
OutputFileFetchFailedError
(
err
=
new
OutputFileFetchFailedError
(
"Output file fetch failed:
#{
linkedFileData
.
build_id
}
,
#{
linkedFileData
.
source_output_file_path
}
"
)
err
.
statusCode
=
response
.
statusCode
...
...
@@ -70,7 +75,7 @@ module.exports = ProjectOutputFileAgent = {
return
callback
(
err
)
if
err
?
callback
(
null
,
file
.
_id
)
# Created
else
err
=
new
LinkedFilesErrors
.
OutputFileFetchFailedError
(
err
=
new
OutputFileFetchFailedError
(
"Output file fetch failed:
#{
linkedFileData
.
build_id
}
,
#{
linkedFileData
.
source_output_file_path
}
"
)
err
.
statusCode
=
response
.
statusCode
...
...
@@ -101,7 +106,7 @@ module.exports = ProjectOutputFileAgent = {
_checkAuth
:
(
project_id
,
data
,
current_user_id
,
callback
=
(
err
,
allowed
)
->
)
->
callback
=
_
.
once
(
callback
)
if
!
@
_validate
(
data
)
return
callback
(
new
LinkedFilesErrors
.
BadDataError
())
return
callback
(
new
BadDataError
())
@
_getSourceProject
data
,
(
err
,
project
)
->
return
callback
(
err
)
if
err
?
AuthorizationManager
.
canUserReadProject
current_user_id
,
...
...
@@ -138,13 +143,13 @@ module.exports = ProjectOutputFileAgent = {
(
err
,
status
,
outputFiles
)
->
return
callback
(
err
)
if
err
?
if
status
!=
'success'
return
callback
(
new
LinkedFilesErrors
.
OutputFileFetchFailedError
())
return
callback
(
new
OutputFileFetchFailedError
())
outputFile
=
_
.
find
(
outputFiles
,
(
o
)
=>
o
.
path
==
source_output_file_path
)
if
!
outputFile
?
return
callback
(
new
LinkedFilesErrors
.
OutputFileFetchFailedError
())
return
callback
(
new
OutputFileFetchFailedError
())
build_id
=
outputFile
.
build
ClsiManager
.
getOutputFileStream
source_project_id
,
user_id
,
...
...
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