feature (offline): handle offline files

This commit is contained in:
MickaelK 2025-06-05 12:58:09 +10:00
parent 7cfc0d497f
commit fb29c7b6c2
4 changed files with 34 additions and 22 deletions

View file

@ -66,6 +66,7 @@ export function createThing({
path = "",
size = 0,
loading = false,
offline = false,
link = "",
view = "",
search = "",
@ -103,7 +104,7 @@ export function createThing({
$filesize.textContent = formatSize(size);
$label.appendChild($filesize);
}
if (mime && view === "grid" && TYPES.THUMBNAILER.has(mime)) {
if (mime && view === "grid" && TYPES.THUMBNAILER.has(mime) && offline === false) {
$extension.classList.add("hidden");
$img.classList.add("thumbnail");
const $placeholder = $img.cloneNode(true);
@ -148,6 +149,11 @@ export function createThing({
} else if (type === "hidden") {
$thing.classList.add("hidden");
return $thing;
} else if (offline) {
$link.removeAttribute("href");
$checkbox.classList.add("hidden");
$thing.style.cursor = "not-allowed";
return $thing;
}
const checked = isSelected(n);

View file

@ -72,9 +72,7 @@ type File struct {
FTime int64 `json:"time"`
FSize int64 `json:"size"`
FPath string `json:"path,omitempty"`
CanRename *bool `json:"can_rename,omitempty"`
CanMove *bool `json:"can_move_directory,omitempty"`
CanDelete *bool `json:"can_delete,omitempty"`
Offline bool `json:"offline,omitempty"`
}
func (f File) Name() string {
@ -103,7 +101,7 @@ func (f File) IsDir() bool {
return true
}
func (f File) Sys() interface{} {
return nil
return f
}
func (f File) Path() string {

View file

@ -25,6 +25,7 @@ type FileInfo struct {
Type string `json:"type"`
Size int64 `json:"size"`
Time int64 `json:"time"`
Offline bool `json:"offline,omitempty"`
}
var (
@ -166,6 +167,9 @@ func FileLs(ctx *App, res http.ResponseWriter, req *http.Request) {
return "directory"
}(entries[i].Mode()),
}
if f, ok := entries[i].Sys().(File); ok && f.Offline == true {
files[i].Offline = true
}
}
etagValue := base64.StdEncoding.EncodeToString(etagger.Sum(nil))

View file

@ -192,7 +192,6 @@ func (this S3Backend) Ls(path string) (files []os.FileInfo, err error) {
FName: *bucket.Name,
FType: "directory",
FTime: bucket.CreationDate.Unix(),
CanMove: NewBool(false),
})
}
return files, nil
@ -214,11 +213,16 @@ func (this S3Backend) Ls(path string) (files []os.FileInfo, err error) {
if object.Size != nil {
size = *object.Size
}
isOffline := false
if object.StorageClass != nil && *object.StorageClass == "GLACIER" {
isOffline = true
}
files = append(files, &File{
FName: filepath.Base(*object.Key),
FType: "file",
FTime: object.LastModified.Unix(),
FSize: size,
Offline: isOffline,
})
}
for _, object := range objs.CommonPrefixes {