Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
debomatic-webui
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
debomatic-webui-admins
debomatic-webui
Commits
f8d310c9
Commit
f8d310c9
authored
Jul 16, 2014
by
Leo Iannacone
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
better code style on utils
parent
70646bc3
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
75 additions
and
100 deletions
+75
-100
debomatic-webui/lib/utils.coffee
debomatic-webui/lib/utils.coffee
+75
-100
No files found.
debomatic-webui/lib/utils.coffee
View file @
f8d310c9
__errors_handler
=
(
from
,
err
,
socket
)
->
path
=
require
(
"path"
)
from
=
"NO SOCKET: "
+
from
unless
socket
fs
=
require
(
"fs"
)
console
.
error
from
,
err
.
message
config
=
require
(
"./config"
)
socket
.
emit
config
.
events
.
error
,
err
.
message
if
socket
Tail
=
require
(
"./tail"
)
return
_
_
check_no_backward
=
(
backward_path
)
->
_check_no_backward
=
(
backward_path
)
->
try
try
return
backward_path
.
indexOf
(
".."
)
<
0
return
backward_path
.
indexOf
(
".."
)
<
0
catch
err
catch
err
return
true
return
true
return
return
__check_data_distribution
=
(
data
)
->
check_data_distribution
=
(
data
)
->
__check_no_backward
(
data
)
and
_check_no_backward
(
data
)
and
__check_no_backward
(
data
.
distribution
)
and
_check_no_backward
(
data
.
distribution
)
and
__check_no_backward
(
data
.
distribution
.
name
)
_check_no_backward
(
data
.
distribution
.
name
)
check_data_package
=
(
data
)
->
check_data_distribution
(
data
)
and
_check_no_backward
(
data
.
package
)
and
_check_no_backward
(
data
.
package
.
name
)
and
_check_no_backward
(
data
.
package
.
version
)
__check_data_package
=
(
data
)
->
__check_data_distribution
(
data
)
and
__check_no_backward
(
data
.
package
)
and
__check_no_backward
(
data
.
package
.
name
)
and
__check_no_backward
(
data
.
package
.
version
)
__
check_data_file
=
(
data
)
->
check_data_file
=
(
data
)
->
__
check_data_package
(
data
)
and
check_data_package
(
data
)
and
_
_
check_no_backward
(
data
.
file
)
and
_check_no_backward
(
data
.
file
)
and
_
_
check_no_backward
(
data
.
file
.
name
)
_check_no_backward
(
data
.
file
.
name
)
__get_distribution_pool_path
=
(
data
)
->
get_distribution_pool_path
=
(
data
)
->
path
.
join
(
config
.
debomatic
.
path
,
data
.
distribution
.
name
,
"pool"
)
path
.
join
(
config
.
debomatic
.
path
,
data
.
distribution
.
name
,
"pool"
)
__get_package_path
=
(
data
)
->
path
.
join
(
__get_distribution_pool_path
(
data
),
data
.
package
.
orig_name
)
__get_file_path
=
(
data
)
->
get_package_path
=
(
data
)
->
path
.
join
(
__get_package_path
(
data
),
path
.
join
(
get_distribution_pool_path
(
data
),
data
.
package
.
orig_name
)
get_file_path
=
(
data
)
->
path
.
join
(
get_package_path
(
data
),
data
.
package
.
orig_name
+
"."
+
data
.
file
.
name
)
data
.
package
.
orig_name
+
"."
+
data
.
file
.
name
)
__
get_files_list
=
(
dir
,
onlyDirectories
,
callback
)
->
get_files_list
=
(
dir
,
onlyDirectories
,
callback
)
->
fs
.
readdir
dir
,
(
err
,
files
)
->
fs
.
readdir
dir
,
(
err
,
files
)
->
result
=
[]
if
err
if
err
__errors_handler
"__get_files_list"
,
err
__errors_handler
"__get_files_list"
,
err
return
return
files
.
forEach
(
f
)
->
result
=
[]
for
f
in
files
try
try
complete_path
=
path
.
join
(
dir
,
f
)
complete_path
=
path
.
join
(
dir
,
f
)
stat
=
fs
.
statSync
(
complete_path
)
stat
=
fs
.
statSync
(
complete_path
)
if
onlyDirectories
if
onlyDirectories
result
.
push
f
if
stat
.
isDirectory
()
result
.
push
(
f
)
if
stat
.
isDirectory
()
else
else
result
.
push
f
if
stat
.
isFile
()
result
.
push
(
f
)
if
stat
.
isFile
()
catch
fs_error
catch
fs_error
__errors_handler
"__get_files_list:forEach"
,
fs_error
__errors_handler
(
"__get_files_list:forEach"
,
fs_error
)
return
continue
return
callback
(
result
)
callback
result
return
return
watch_path_onsocket
=
(
event_name
,
socket
,
data
,
watch_path
,
updater
)
->
__watch_path_onsocket
=
(
event_name
,
socket
,
data
,
watch_path
,
updater
)
->
socket_watchers
=
socket
.
watchers
or
{}
socket_watchers
=
socket
.
watchers
or
{}
try
try
watcher
=
socket_watchers
[
event_name
]
watcher
=
socket_watchers
[
event_name
]
watcher
.
close
()
if
watcher
watcher
.
close
()
if
watcher
fs
.
stat
watch_path
,
(
err
,
stats
)
->
fs
.
stat
watch_path
,
(
err
,
stats
)
->
if
err
if
err
__errors_handler
"__watch_path_onsocket:fs.stat"
,
err
,
socket
__errors_handler
(
"__watch_path_onsocket:fs.stat"
,
err
,
socket
)
return
return
if
stats
.
isDirectory
()
if
stats
.
isDirectory
()
watcher
=
fs
.
watch
(
watch_path
,
watcher
=
fs
.
watch
(
watch_path
,
persistent
:
true
persistent
:
true
,
,
(
event
,
fileName
)
->
(
event
,
fileName
)
->
updater
event_name
,
socket
,
data
if
event
is
"rename"
if
ev
is
"rename"
return
updater
(
event_name
,
socket
,
data
))
)
else
if
stats
.
isFile
()
else
if
stats
.
isFile
()
watcher
=
new
Tail
(
watch_path
)
watcher
=
new
Tail
(
watch_path
)
watcher
.
on
"line"
,
(
new_content
,
tailInfo
)
->
watcher
.
on
(
"line"
,
(
new_content
,
tailInfo
)
->
data
.
file
.
new_content
=
new_content
+
"
\n
"
data
.
file
.
new_content
=
new_content
+
"
\n
"
updater
event_name
,
socket
,
data
updater
event_name
,
socket
,
data
)
return
watcher
.
on
"error"
,
(
msg
)
->
watcher
.
on
"error"
,
(
msg
)
->
socket
.
emit
config
.
events
.
error
,
msg
socket
.
emit
config
.
events
.
error
,
msg
return
socket_watchers
[
event_name
]
=
watcher
socket_watchers
[
event_name
]
=
watcher
socket
.
watchers
=
socket_watchers
socket
.
watchers
=
socket_watchers
return
catch
err
catch
err
__
errors_handler
(
"__watch_path_onsocket <- "
+
errors_handler
(
"__watch_path_onsocket <- "
+
arguments_
.
callee
.
caller
.
name
,
arguments_
.
callee
.
caller
.
name
,
err
,
err
,
socket
)
socket
)
return
return
return
__generic_handler_watcher
=
(
event_name
,
socket
,
data
,
watch_path
,
callback
)
->
generic_handler_watcher
=
(
event_name
,
socket
,
data
,
watch_path
,
callback
)
->
callback
event_name
,
socket
,
data
callback
event_name
,
socket
,
data
__
watch_path_onsocket
event_name
,
socket
,
data
,
watch_path
,
callback
watch_path_onsocket
event_name
,
socket
,
data
,
watch_path
,
callback
return
__
send_distributions
=
(
socket
)
->
send_distributions
=
(
socket
)
->
__
get_files_list
config
.
debomatic
.
path
,
true
,
(
directories
)
->
get_files_list
config
.
debomatic
.
path
,
true
,
(
directories
)
->
distributions
=
[]
distributions
=
[]
directories
.
forEach
(
dir
)
->
for
dir
in
directories
data
=
{}
data
=
{}
data
.
distribution
=
{}
data
.
distribution
=
{}
data
.
distribution
.
name
=
dir
data
.
distribution
.
name
=
dir
pool_path
=
__
get_distribution_pool_path
(
data
)
pool_path
=
get_distribution_pool_path
(
data
)
distributions
.
push
dir
if
fs
.
existsSync
(
pool_path
)
distributions
.
push
dir
if
fs
.
existsSync
(
pool_path
)
return
socket
.
emit
config
.
events
.
broadcast
.
distributions
,
distributions
socket
.
emit
config
.
events
.
broadcast
.
distributions
,
distributions
return
return
path
=
require
(
"path"
)
fs
=
require
(
"fs"
)
config
=
require
(
"./config"
)
Tail
=
require
(
"./tail"
)
utils
=
check_data_distribution
:
(
data
)
->
__check_data_distribution
data
check_data_package
:
(
data
)
->
errors_handler
=
(
from
,
error
,
socket
)
->
__check_data_package
data
from
=
"NO SOCKET: "
+
from
unless
socket
console
.
error
from
,
err
.
message
check_data_file
:
(
data
)
->
socket
.
emit
config
.
events
.
error
,
err
.
message
if
socket
__check_data_file
data
return
get_distribution_pool_path
:
(
data
)
->
__get_distribution_pool_path
data
get_package_path
:
(
data
)
->
__get_package_path
data
get_file_path
:
(
data
)
->
__get_file_path
data
get_files_list
:
(
dir
,
onlyDirectories
,
callback
)
->
__get_files_list
dir
,
onlyDirectories
,
callback
watch_path_onsocket
:
(
event_name
,
socket
,
data
,
watch_path
,
updater
)
->
__watch_path_onsocket
event_name
,
socket
,
data
,
watch_path
,
updater
generic_handler_watcher
:
(
event_name
,
socket
,
data
,
watch_path
,
callback
)
->
__generic_handler_watcher
event_name
,
socket
,
data
,
watch_path
,
callback
send_distributions
:
(
socket
)
->
__send_distributions
socket
errors_handler
:
(
from
,
error
,
socket
)
->
__errors_handler
from
,
error
,
socket
module
.
exports
=
utils
module
.
exports
.
check_data_distribution
=
check_data_distribution
module
.
exports
.
check_data_package
=
check_data_package
module
.
exports
.
check_data_file
=
check_data_file
module
.
exports
.
get_distribution_pool_path
=
get_distribution_pool_path
module
.
exports
.
get_package_path
=
get_package_path
module
.
exports
.
get_file_path
=
get_file_path
module
.
exports
.
get_files_list
=
get_files_list
module
.
exports
.
watch_path_onsocket
=
watch_path_onsocket
module
.
exports
.
generic_handler_watcher
=
generic_handler_watcher
module
.
exports
.
send_distributions
=
send_distributions
module
.
exports
.
errors_handler
=
errors_handler
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