qs: preload NotesService & scripts: update xgo
This commit is contained in:
@@ -72,7 +72,7 @@ Singleton {
|
||||
Logger.e("Notes", `Failed to create note file: ${ret}`);
|
||||
return ;
|
||||
}
|
||||
notesModel.append(currentNote);
|
||||
root.notesModel.append(currentNote);
|
||||
const toOpen = currentNote.notePath;
|
||||
currentNote = null;
|
||||
root.openNote(toOpen);
|
||||
@@ -89,17 +89,17 @@ Singleton {
|
||||
Logger.e("Notes", `Failed to delete note file: ${ret}`);
|
||||
return ;
|
||||
}
|
||||
for (let i = 0; i < notesModel.count; i++) {
|
||||
if (notesModel.get(i).notePath === currentPath) {
|
||||
notesModel.remove(i);
|
||||
for (let i = 0; i < root.notesModel.count; i++) {
|
||||
if (root.notesModel.get(i).notePath === currentPath) {
|
||||
root.notesModel.remove(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (recentNotePath === currentPath)
|
||||
if (notesModel.count > 0)
|
||||
recentNotePath = notesModel.get(0).notePath;
|
||||
if (root.recentNotePath === currentPath)
|
||||
if (root.notesModel.count > 0)
|
||||
root.recentNotePath = root.notesModel.get(0).notePath;
|
||||
else
|
||||
recentNotePath = "";;
|
||||
root.recentNotePath = "";;
|
||||
|
||||
currentPath = "";
|
||||
}
|
||||
@@ -116,20 +116,20 @@ Singleton {
|
||||
|
||||
onStreamFinished: {
|
||||
const files = listCollector.text.split('\n');
|
||||
notesModel.clear();
|
||||
root.notesModel.clear();
|
||||
for (var i = 0; i < files.length; i++) {
|
||||
const fileName = files[i].trim();
|
||||
if (!fileName || !fileName.endsWith(".txt"))
|
||||
continue;
|
||||
|
||||
notesModel.append({
|
||||
root.notesModel.append({
|
||||
"notePath": Paths.notesDir + "/" + fileName,
|
||||
"colorIdx": strToColor(fileName)
|
||||
});
|
||||
Logger.d("Notes", "Loaded note: " + fileName);
|
||||
}
|
||||
if (notesModel.count > 0)
|
||||
recentNotePath = notesModel.get(0).notePath;
|
||||
if (root.notesModel.count > 0)
|
||||
root.recentNotePath = root.notesModel.get(0).notePath;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ ShellRoot {
|
||||
sourceComponent: Item {
|
||||
Component.onCompleted: {
|
||||
SunsetService;
|
||||
NotesService;
|
||||
}
|
||||
|
||||
IPCService {
|
||||
|
||||
@@ -10,6 +10,7 @@ import sys
|
||||
import tempfile
|
||||
import tarfile
|
||||
import zipfile
|
||||
import requests
|
||||
from pathlib import Path
|
||||
|
||||
DEFAULT_SHELL = "bash"
|
||||
@@ -17,6 +18,23 @@ DEFAULT_TMPFS_SIZE = "8G"
|
||||
SIZE_PATTERN = re.compile(r"^[1-9][0-9]*[KMGkmg]?$")
|
||||
|
||||
|
||||
def download_to(url: str, dest_dir: Path) -> Path:
|
||||
local_filename = url.split('/')[-1]
|
||||
dest_path = dest_dir / local_filename
|
||||
|
||||
print(f"Downloading '{url}' to '{dest_path}'...")
|
||||
try:
|
||||
with requests.get(url, stream=True) as r:
|
||||
r.raise_for_status()
|
||||
with open(dest_path, 'wb') as f:
|
||||
for chunk in r.iter_content(chunk_size=8192):
|
||||
f.write(chunk)
|
||||
except Exception as e:
|
||||
sys.exit(f"Error: Failed to download '{url}': {e}")
|
||||
|
||||
return dest_path
|
||||
|
||||
|
||||
def check_dependencies(use_tmpfs: bool, is_zip: bool, is_tar: bool):
|
||||
deps = []
|
||||
if use_tmpfs:
|
||||
@@ -92,7 +110,7 @@ def extract_archive(archive_path: Path, dest_dir: Path, strip_components: int =
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description="Extract an archive to a directory and spawn a shell.")
|
||||
parser.add_argument("archive", type=Path, help="Path to the tarball or zip file")
|
||||
parser.add_argument("archive", type=str, help="Path to the tarball or zip file")
|
||||
parser.add_argument("--exec", "-e", dest="cmd", default=DEFAULT_SHELL,
|
||||
help=f"Command to spawn (default: '{DEFAULT_SHELL}')")
|
||||
parser.add_argument("--target", "-t", type=Path, help="Target directory for extraction.")
|
||||
@@ -104,6 +122,11 @@ def main():
|
||||
args = parser.parse_args()
|
||||
archive = args.archive.resolve()
|
||||
|
||||
if archive.suffix in ['https://', 'http://']:
|
||||
archive = download_to(archive, Path.cwd())
|
||||
else:
|
||||
archive = Path(args.archive).resolve()
|
||||
|
||||
if not archive.exists() or not archive.is_file():
|
||||
sys.exit(f"Error: Archive '{archive}' does not exist or is not a file.")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user