added "Fixed not selecting the file just uploaded" - 9ee6171
This commit is contained in:
@@ -54,7 +54,7 @@ module.exports = {
|
||||
|
||||
methods: {
|
||||
load: async function(file) {
|
||||
if (file == this.file) {
|
||||
if (file != this.file) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,10 @@ class FileHandler(bbctrl.APIHandler):
|
||||
|
||||
filename = self.request.path.split('/')[-1]
|
||||
self.uploadFilename = url_unescape(filename) \
|
||||
.replace('\\', '/') \
|
||||
.encode("ascii", errors="replace") \
|
||||
.decode() \
|
||||
.replace('\\', '_') \
|
||||
.replace('/', '_') \
|
||||
.replace('#', '-') \
|
||||
.replace('?', '-')
|
||||
|
||||
@@ -71,7 +74,8 @@ class FileHandler(bbctrl.APIHandler):
|
||||
def get(self, filename):
|
||||
if not filename:
|
||||
raise HTTPError(400, 'Missing filename')
|
||||
filename = os.path.basename(filename)
|
||||
|
||||
filename = os.path.basename(url_unescape(filename))
|
||||
|
||||
try:
|
||||
with open(self.get_upload(filename).encode('utf8'), 'r') as f:
|
||||
|
||||
@@ -32,7 +32,7 @@ import os
|
||||
import bbctrl
|
||||
from watchdog.observers import Observer
|
||||
from watchdog.events import FileSystemEventHandler
|
||||
|
||||
import glob
|
||||
class UploadChangeHandler(FileSystemEventHandler):
|
||||
def __init__(self, state):
|
||||
self.state = state
|
||||
@@ -123,14 +123,12 @@ class State(object):
|
||||
|
||||
if not os.path.exists(upload):
|
||||
os.mkdir(upload)
|
||||
from shutil import copy
|
||||
copy(bbctrl.get_resource('http/buildbotics.nc'), upload)
|
||||
|
||||
for path in os.listdir(upload):
|
||||
if os.path.isfile(upload + '/' + path):
|
||||
files.append(path)
|
||||
files = filter(os.path.isfile, glob.glob(upload + '/*'))
|
||||
# Sort list of files based on last modification time in ascending order
|
||||
files = sorted(files, key=os.path.getmtime, reverse=True)
|
||||
files = list(map(lambda f: f.replace("./upload/", ""), files))
|
||||
|
||||
files.sort()
|
||||
self.set('files', files)
|
||||
|
||||
if len(files): self.select_file(files[0])
|
||||
|
||||
Reference in New Issue
Block a user