Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
hidra
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
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
steinbac
hidra
Commits
0cbe21b8
Commit
0cbe21b8
authored
9 years ago
by
Manuela Kuhn
Browse files
Options
Downloads
Patches
Plain Diff
Added safeguard: files only get removed if stored
parent
fb3bfe2b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/sender/dataFetchers/getFromHttp.py
+19
-8
19 additions, 8 deletions
src/sender/dataFetchers/getFromHttp.py
with
19 additions
and
8 deletions
src/sender/dataFetchers/getFromHttp.py
+
19
−
8
View file @
0cbe21b8
...
...
@@ -99,12 +99,16 @@ def sendData (log, targets, sourceFile, targetFile, metadata, openConnections,
except
:
log
.
error
(
"
Unable to get chunkSize
"
,
exc_info
=
True
)
prop
[
"
removeFlag
"
]
=
prop
[
"
removeData
"
]
fileOpened
=
False
fileWritten
=
True
fileClosed
=
False
fileSend
=
True
if
prop
[
"
storeData
"
]:
try
:
log
.
debug
(
"
Opening
'"
+
str
(
targetFile
)
+
"'
...
"
)
fileDescriptor
=
open
(
str
(
targetFile
),
"
wb
"
)
fileOpened
=
True
except
IOError
,
e
:
# errno.ENOENT == "No such file or directory"
if
e
.
errno
==
errno
.
ENOENT
:
...
...
@@ -114,32 +118,29 @@ def sendData (log, targets, sourceFile, targetFile, metadata, openConnections,
if
metadata
[
"
relativePath
"
]
in
prop
[
"
fixSubdirs
"
]:
log
.
error
(
"
Unable to move file
'"
+
sourceFile
+
"'
to
'"
+
targetFile
+
"
: Directory
"
+
metadata
[
"
relativePath
"
]
+
"
is not available
"
,
exc_info
=
True
)
prop
[
"
removeFlag
"
]
=
False
elif
subdir
in
prop
[
"
fixSubdirs
"
]
:
log
.
error
(
"
Unable to move file
'"
+
sourceFile
+
"'
to
'"
+
targetFile
+
"
: Directory
"
+
subdir
+
"
is not available
"
,
exc_info
=
True
)
prop
[
"
removeFlag
"
]
=
False
else
:
try
:
targetPath
,
filename
=
os
.
path
.
split
(
targetFile
)
os
.
makedirs
(
targetPath
)
fileDescriptor
=
open
(
targetFile
,
"
w
"
)
log
.
info
(
"
New target directory created:
"
+
str
(
targetPath
))
fileOpened
=
True
except
OSError
,
e
:
log
.
info
(
"
Target directory creation failed, was already created in the meantime:
"
+
str
(
targetPath
))
fileDescriptor
=
open
(
targetFile
,
"
w
"
)
fileOpened
=
True
except
:
log
.
error
(
"
Unable to open target file
'"
+
targetFile
+
"'
.
"
,
exc_info
=
True
)
log
.
debug
(
"
targetPath:
"
+
str
(
targetPath
))
prop
[
"
removeFlag
"
]
=
False
raise
else
:
log
.
error
(
"
Unable to open target file
'"
+
targetFile
+
"'
.
"
,
exc_info
=
True
)
prop
[
"
removeFlag
"
]
=
False
except
:
log
.
error
(
"
Unable to open target file
'"
+
targetFile
+
"'
.
"
,
exc_info
=
True
)
log
.
debug
(
"
e.errno =
"
+
str
(
e
.
errno
)
+
"
errno.EEXIST==
"
+
str
(
errno
.
EEXIST
))
prop
[
"
removeFlag
"
]
=
False
targets_data
=
[
i
for
i
in
targets
if
i
[
2
]
==
"
data
"
]
targets_metadata
=
[
i
for
i
in
targets
if
i
[
2
]
==
"
metadata
"
]
...
...
@@ -162,7 +163,12 @@ def sendData (log, targets, sourceFile, targetFile, metadata, openConnections,
log
.
error
(
"
Unable to pack multipart-message for file
"
+
str
(
sourceFile
),
exc_info
=
True
)
if
prop
[
"
storeData
"
]:
fileDescriptor
.
write
(
data
)
try
:
fileDescriptor
.
write
(
data
)
except
:
log
.
error
(
"
Unable write data for file
"
+
str
(
sourceFile
),
exc_info
=
True
)
fileWritten
=
False
#send message to data targets
try
:
...
...
@@ -171,6 +177,7 @@ def sendData (log, targets, sourceFile, targetFile, metadata, openConnections,
except
:
log
.
error
(
"
Unable to send multipart-message for file
"
+
str
(
sourceFile
),
exc_info
=
True
)
fileSend
=
False
chunkNumber
+=
1
...
...
@@ -178,7 +185,7 @@ def sendData (log, targets, sourceFile, targetFile, metadata, openConnections,
try
:
log
.
debug
(
"
Closing
'"
+
str
(
targetFile
)
+
"'
...
"
)
fileDescriptor
.
close
()
prop
[
"
removeFlag
"
]
=
True
fileClosed
=
True
except
:
log
.
error
(
"
Unable to close target file
'"
+
str
(
targetFile
)
+
"'
.
"
,
exc_info
=
True
)
raise
...
...
@@ -195,6 +202,10 @@ def sendData (log, targets, sourceFile, targetFile, metadata, openConnections,
except
:
log
.
error
(
"
Unable to send metadata multipart-message for file
"
+
str
(
sourceFile
),
exc_info
=
True
)
prop
[
"
removeFlag
"
]
=
fileOpened
and
fileWritten
and
fileClosed
else
:
prop
[
"
removeFlag
"
]
=
fileSend
def
finishDataHandling
(
log
,
targets
,
sourceFile
,
targetFile
,
metadata
,
openConnections
,
context
,
prop
):
...
...
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