Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rsyncd优化 #694

Merged
merged 5 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 21 additions & 9 deletions plugins/rsyncd/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,21 +281,33 @@ def rsyncOp(method):
return 'fail'


def start():
return rsyncOp('start')
def lsyncdOp(method):
if not mw.isAppleSystem():
data = mw.execShell('systemctl ' + method + ' lsyncd')
if data[1] == '':
return 'ok'
return 'fail'
return 'fail'

def start():
status = rsyncOp('start')
lsyncdOp('start')
return status

def stop():
return rsyncOp('stop')

status = rsyncOp('stop')
lsyncdOp('stop')
return status

def restart():
return rsyncOp('restart')

status = rsyncOp('restart')
lsyncdOp('restart')
return status

def reload():
return rsyncOp('reload')

status = rsyncOp('reload')
lsyncdOp('reload')
return status

def initdStatus():
if mw.isAppleSystem():
Expand Down Expand Up @@ -722,7 +734,7 @@ def lsyncdAdd():
import base64

args = getArgs()
data = checkArgs(args, ['ip', 'conn_type', 'path', 'delay', 'period'])
data = checkArgs(args, ['ip', 'conn_type', 'path', 'delay', 'period', 'bwlimit'])
if not data[0]:
return data[1]

Expand Down
13 changes: 11 additions & 2 deletions plugins/rsyncd/js/rsyncd.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,15 @@ function createSendTask(name = ''){
period_minute_n = "selected";
}

var bwlimit = "1024";
if ('rsync' in data){
bwlimit = data['rsync']['bwlimit'];
}

var delay = "3";
if ('delay' in data){
delay = data['delay'];
}

var layerID = layer.open({
type: 1,
Expand Down Expand Up @@ -146,9 +155,9 @@ function createSendTask(name = ''){
<div class='line'>\
<span class='tname'>限速</span>\
<div class='info-r c4'>\
<input class='bt-input-text' type='number' name='bwlimit' min='0' value='1024' style='width:100px' /> KB\
<input class='bt-input-text' type='number' name='bwlimit' min='0' value='"+bwlimit+"' style='width:100px' /> KB\
<span data-toggle='tooltip' data-placement='top' title='【限速】限制数据同步任务的速度,防止因同步数据导致带宽跑高' class='bt-ico-ask' style='cursor: pointer;'>?</span>\
<span style='margin-left: 29px;margin-right: 10px;'>延迟</span><input class='bt-input-text' min='0' type='number' name='delay' value='3' style='width:100px' /> 秒\
<span style='margin-left: 29px;margin-right: 10px;'>延迟</span><input class='bt-input-text' min='0' type='number' name='delay' value='"+delay+"' style='width:100px' /> 秒\
<span data-toggle='tooltip' data-placement='top' title='【延迟】在延迟时间周期内仅记录不同步,到达周期后一次性同步数据,以节省开销' class='bt-ico-ask' style='cursor: pointer;'>?</span>\
</div>\
</div>\
Expand Down
15 changes: 11 additions & 4 deletions web/utils/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,10 +496,17 @@ def saveBody(path, data, encoding):
def sortFileList(path, ftype = 'mtime', sort = 'desc'):
flist = os.listdir(path)
if ftype == 'mtime':
if sort == 'desc':
flist = sorted(flist, key=lambda f: os.path.getmtime(os.path.join(path,f)), reverse=True)
if sort == 'asc':
flist = sorted(flist, key=lambda f: os.path.getmtime(os.path.join(path,f)), reverse=False)
try:
if sort == 'desc':
flist = sorted(flist, key=lambda f: os.path.getmtime(os.path.join(path,f)), reverse=True)
if sort == 'asc':
flist = sorted(flist, key=lambda f: os.path.getmtime(os.path.join(path,f)), reverse=False)
except Exception as e:
if sort == 'desc':
flist = sorted(flist, key=lambda f: os.path.getctime(os.path.join(path,f)), reverse=True)
if sort == 'asc':
flist = sorted(flist, key=lambda f: os.path.getctime(os.path.join(path,f)), reverse=False)


if ftype == 'size':
if sort == 'desc':
Expand Down
Loading