Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
keeleliin
keeleliin-wrapper
Commits
1515c21c
Commit
1515c21c
authored
Sep 15, 2015
by
priit
Browse files
Utiliidi töö katkestamine
parent
40360d25
Changes
1
Hide whitespace changes
Inline
Side-by-side
wrapper/archiveExtractor.js
View file @
1515c21c
...
...
@@ -41,21 +41,32 @@ function ArchiveExtractor() {
logger
.
debug
(
'
Extracting *.zip file
'
);
var
checkForCallback
=
function
()
{
if
(
count
==
0
)
{
session
.
message
=
Session
.
messages
.
OK
;
return
callback
(
null
,
session
);
}
};
fs
.
createReadStream
(
file
).
on
(
'
error
'
,
function
(
error
)
{
session
.
setErrors
(
error
);
return
callback
(
error
,
session
);
})
.
pipe
(
unzip
.
Parse
())
.
on
(
'
entry
'
,
function
(
entry
)
{
var
savePath
=
SessionService
.
getStorePath
(
session
.
id
);
var
isFile
=
(
'
File
'
==
entry
.
type
);
var
fullpath
=
path
.
join
(
savePath
,
entry
.
path
);
//logger.debug('Fullpath: ' + fullpath);
var
directory
=
(
isFile
?
path
.
dirname
(
fullpath
)
:
fullpath
);
if
(
isFile
)
{
count
++
;
}
var
savePath
=
SessionService
.
getStorePath
(
session
.
id
);
var
fullpath
=
path
.
join
(
savePath
,
entry
.
path
);
logger
.
debug
(
'
Fullpath:
'
+
fullpath
);
var
directory
=
(
isFile
?
path
.
dirname
(
fullpath
)
:
fullpath
);
logger
.
debug
(
'
Countx:
'
+
count
);
mkdirp
(
directory
,
function
(
err
)
{
...
...
@@ -77,10 +88,7 @@ function ArchiveExtractor() {
contentType
:
mime
.
lookup
(
fullpath
)
// getting the original file mime type
});
count
--
;
//logger.debug('Countx: ' + count);
if
(
count
==
0
)
{
session
.
message
=
Session
.
messages
.
OK
;
}
checkForCallback
();
});
}
else
{
entry
.
autodrain
();
...
...
@@ -89,11 +97,7 @@ function ArchiveExtractor() {
})
.
on
(
'
close
'
,
function
()
{
logger
.
debug
(
'
Close count:
'
+
count
);
if
(
count
==
0
)
{
session
.
message
=
Session
.
messages
.
OK
;
}
return
callback
(
null
,
session
);
checkForCallback
();
});
};
...
...
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