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
dcf56327
Commit
dcf56327
authored
Mar 08, 2014
by
Leo Iannacone
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use only a function to handle with watchers
parent
fa1dac59
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
40 deletions
+32
-40
debomatic-webui/app.js
debomatic-webui/app.js
+32
-40
No files found.
debomatic-webui/app.js
View file @
dcf56327
...
@@ -38,62 +38,54 @@ var io = require('socket.io').listen(app);
...
@@ -38,62 +38,54 @@ var io = require('socket.io').listen(app);
// Routes
// Routes
app
.
get
(
'
/
'
,
routes
.
index
);
app
.
get
(
'
/
'
,
routes
.
index
);
function
watcher_on_socket
(
event_name
,
socket
,
data
,
watch_path
,
updater
)
{
name
=
"
watcher-
"
+
event_name
socket
.
get
(
name
,
function
(
err
,
watcher
)
{
if
(
watcher
)
watcher
.
close
()
try
{
watcher
=
fs
.
watch
(
watch_path
,
{
persistent
:
true
},
function
(
event
,
fileName
)
{
if
(
event
==
'
rename
'
)
updater
(
socket
,
data
)
})
socket
.
set
(
name
,
watcher
)
}
catch
(
err_watch
)
{}
})
}
function
check_data_distribution
(
data
)
{
return
data
&&
data
.
distribution
&&
data
.
distribution
.
name
}
function
check_data_package
(
data
)
{
return
check_data_distribution
(
data
)
&&
data
.
package
&&
data
.
package
.
name
&&
data
.
package
.
version
}
io
.
sockets
.
on
(
'
connection
'
,
function
(
socket
)
{
io
.
sockets
.
on
(
'
connection
'
,
function
(
socket
)
{
send
.
distributions
(
socket
);
send
.
distributions
(
socket
);
// send distribution packages
// send distribution packages
socket
.
on
(
'
get_distribution_packages
'
,
function
(
data
)
{
socket
.
on
(
'
get_distribution_packages
'
,
function
(
data
)
{
if
(
!
data
)
if
(
!
check_data_distribution
(
data
)
)
return
return
socket
.
get
(
"
watcher-distribution-packages
"
,
function
(
err
,
watcher
){
distribution_path
=
path
.
join
(
config
.
debomatic_path
,
data
.
distribution
.
name
,
'
pool
'
)
if
(
watcher
)
watcher_on_socket
(
'
get_distribution_packages
'
,
socket
,
data
,
distribution_path
,
send
.
distribution_packages
)
watcher
.
close
()
if
(
!
data
.
distribution
||
!
data
.
distribution
.
name
)
return
packages_path
=
path
.
join
(
config
.
debomatic_path
,
data
.
distribution
.
name
,
'
pool
'
)
// watch for incoming packages
try
{
watcher
=
fs
.
watch
(
packages_path
,
{
persistent
:
true
},
function
(
event
,
fileName
)
{
if
(
event
==
'
rename
'
)
send
.
distribution_packages
(
socket
,
data
);
});
socket
.
set
(
'
watcher-distribution-packages
'
,
watcher
);
}
catch
(
err
)
{}
})
send
.
distribution_packages
(
socket
,
data
);
send
.
distribution_packages
(
socket
,
data
);
})
})
socket
.
on
(
'
get_package_file_list
'
,
function
(
data
)
{
socket
.
on
(
'
get_package_file_list
'
,
function
(
data
)
{
if
(
!
data
)
if
(
!
check_data_package
(
data
)
)
return
return
socket
.
get
(
'
wather-package-files-list
'
,
function
(
err
,
watcher
)
{
package_path
=
path
.
join
(
config
.
debomatic_path
,
data
.
distribution
.
name
,
'
pool
'
,
data
.
package
.
name
+
"
_
"
+
data
.
package
.
version
)
if
(
watcher
)
watcher_on_socket
(
'
get_package_file_list
'
,
socket
,
data
,
package_path
,
send
.
package_file_list
)
watcher
.
close
()
send
.
package_file_list
(
socket
,
data
)
if
(
!
data
.
distribution
||
!
data
.
distribution
.
name
||
!
data
.
package
||
!
data
.
package
.
name
||
!
data
.
package
.
version
)
return
package_path
=
path
.
join
(
config
.
debomatic_path
,
data
.
distribution
.
name
,
'
pool
'
,
data
.
package
.
name
+
"
_
"
+
data
.
package
.
version
)
try
{
watcher
=
fs
.
watch
(
package_path
,
{
persistent
:
true
},
function
(
event
,
fileName
)
{
if
(
event
==
'
rename
'
)
send
.
package_file_list
(
socket
,
data
);
});
socket
.
set
(
'
watcher-package-files-list
'
,
watcher
);
}
catch
(
err
)
{}
})
send
.
package_file_list
(
socket
,
data
);
})
})
});
});
io
.
sockets
.
on
(
'
disconnect
'
,
function
(
socket
){
io
.
sockets
.
on
(
'
disconnect
'
,
function
(
socket
){
socket
.
get
(
'
watchers
'
,
function
(
err
,
watchers
)
{
if
(
watchers
)
watchers
.
forEach
(
function
(
w
){
w
.
close
()
});
socket
.
set
(
'
watchers
'
,
[]);
});
});
});
fs
.
watch
(
config
.
debomatic_path
,
{
persistent
:
true
},
function
(
event
,
fileName
)
{
fs
.
watch
(
config
.
debomatic_path
,
{
persistent
:
true
},
function
(
event
,
fileName
)
{
...
...
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