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
359d06e7
Commit
359d06e7
authored
Mar 09, 2014
by
Leo Iannacone
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
moved watch_path_onsocket to utils
parent
f6f16d2f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
36 deletions
+39
-36
debomatic-webui/lib/client.js
debomatic-webui/lib/client.js
+2
-36
debomatic-webui/lib/utils.js
debomatic-webui/lib/utils.js
+37
-0
No files found.
debomatic-webui/lib/client.js
View file @
359d06e7
var
fs
=
require
(
'
fs
'
)
var
fs
=
require
(
'
fs
'
)
,
path
=
require
(
'
path
'
)
,
path
=
require
(
'
path
'
)
,
Tail
=
require
(
'
tail
'
).
Tail
,
config
=
require
(
'
./config.js
'
)
,
config
=
require
(
'
./config.js
'
)
,
utils
=
require
(
'
./utils.js
'
)
,
utils
=
require
(
'
./utils.js
'
)
...
@@ -78,47 +77,14 @@ function __send_distributions(event_name, socket, data) {
...
@@ -78,47 +77,14 @@ function __send_distributions(event_name, socket, data) {
});
});
}
}
function
__watch_path_onsocket
(
event_name
,
socket
,
data
,
watch_path
,
updater
)
{
name
=
"
watcher-
"
+
event_name
socket
.
get
(
name
,
function
(
err
,
watcher
)
{
if
(
watcher
)
{
try
{
watcher
.
unwatch
()
}
catch
(
errorWatchingDirectory
)
{
watcher
.
close
()
}
}
try
{
fs
.
stat
(
watch_path
,
function
(
err
,
stats
)
{
if
(
err
)
return
if
(
stats
.
isDirectory
())
{
watcher
=
fs
.
watch
(
watch_path
,
{
persistent
:
true
},
function
(
event
,
fileName
)
{
if
(
event
==
'
rename
'
)
updater
(
event_name
,
socket
,
data
)
})
}
else
{
watcher
=
new
Tail
(
watch_path
)
watcher
.
on
(
'
line
'
,
function
(
new_content
)
{
data
.
file
.
new_content
=
new_content
+
'
\n
'
updater
(
event_name
,
socket
,
data
)
})
}
socket
.
set
(
name
,
watcher
)
})
}
catch
(
err_watch
)
{}
})
}
function
__generic_handler
(
event_name
,
socket
,
data
,
watch_path
,
callback
)
{
function
__generic_handler
(
event_name
,
socket
,
data
,
watch_path
,
callback
)
{
__
watch_path_onsocket
(
event_name
,
socket
,
data
,
config
.
debomatic
.
path
,
callback
)
utils
.
watch_path_onsocket
(
event_name
,
socket
,
data
,
config
.
debomatic
.
path
,
callback
)
callback
(
event_name
,
socket
,
data
)
callback
(
event_name
,
socket
,
data
)
}
}
function
__handler_get_file
(
socket
,
data
)
{
function
__handler_get_file
(
socket
,
data
)
{
file_path
=
utils
.
get_file_path
(
data
)
file_path
=
utils
.
get_file_path
(
data
)
__
watch_path_onsocket
(
'
file_newcontent
'
,
socket
,
data
,
file_path
,
__handler_file_newcontent
)
utils
.
watch_path_onsocket
(
'
file_newcontent
'
,
socket
,
data
,
file_path
,
__handler_file_newcontent
)
__send_file
(
'
file
'
,
socket
,
data
)
__send_file
(
'
file
'
,
socket
,
data
)
}
}
...
...
debomatic-webui/lib/utils.js
View file @
359d06e7
var
path
=
require
(
'
path
'
)
var
path
=
require
(
'
path
'
)
,
fs
=
require
(
'
fs
'
)
,
fs
=
require
(
'
fs
'
)
,
Tail
=
require
(
'
tail
'
).
Tail
,
config
=
require
(
'
./config.js
'
)
,
config
=
require
(
'
./config.js
'
)
function
__check_data_distribution
(
data
)
{
function
__check_data_distribution
(
data
)
{
...
@@ -52,6 +53,39 @@ function __get_files_list(dir, onlyDirectories, callback) {
...
@@ -52,6 +53,39 @@ function __get_files_list(dir, onlyDirectories, callback) {
});
});
}
}
function
__watch_path_onsocket
(
event_name
,
socket
,
data
,
watch_path
,
updater
)
{
name
=
"
watcher-
"
+
event_name
socket
.
get
(
name
,
function
(
err
,
watcher
)
{
if
(
watcher
)
{
try
{
watcher
.
unwatch
()
}
catch
(
errorWatchingDirectory
)
{
watcher
.
close
()
}
}
try
{
fs
.
stat
(
watch_path
,
function
(
err
,
stats
)
{
if
(
err
)
return
if
(
stats
.
isDirectory
())
{
watcher
=
fs
.
watch
(
watch_path
,
{
persistent
:
true
},
function
(
event
,
fileName
)
{
if
(
event
==
'
rename
'
)
updater
(
event_name
,
socket
,
data
)
})
}
else
{
watcher
=
new
Tail
(
watch_path
)
watcher
.
on
(
'
line
'
,
function
(
new_content
)
{
data
.
file
.
new_content
=
new_content
+
'
\n
'
updater
(
event_name
,
socket
,
data
)
})
}
socket
.
set
(
name
,
watcher
)
})
}
catch
(
err_watch
)
{}
})
}
utils
=
{
utils
=
{
check_data_distribution
:
function
(
data
)
{
check_data_distribution
:
function
(
data
)
{
return
__check_data_distribution
(
data
)
return
__check_data_distribution
(
data
)
...
@@ -73,6 +107,9 @@ utils = {
...
@@ -73,6 +107,9 @@ utils = {
},
},
get_files_list
:
function
(
dir
,
onlyDirectories
,
callback
)
{
get_files_list
:
function
(
dir
,
onlyDirectories
,
callback
)
{
return
__get_files_list
(
dir
,
onlyDirectories
,
callback
)
return
__get_files_list
(
dir
,
onlyDirectories
,
callback
)
},
watch_path_onsocket
:
function
(
event_name
,
socket
,
data
,
watch_path
,
updater
)
{
return
__watch_path_onsocket
(
event_name
,
socket
,
data
,
watch_path
,
updater
)
}
}
}
}
...
...
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