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