mirror of
https://github.com/mickael-kerjean/filestash
synced 2025-12-06 08:22:24 +01:00
feature (offline): handle offline files
This commit is contained in:
parent
7cfc0d497f
commit
fb29c7b6c2
4 changed files with 34 additions and 22 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -67,14 +67,12 @@ type AuditQueryResult struct {
|
|||
}
|
||||
|
||||
type File struct {
|
||||
FName string `json:"name"`
|
||||
FType string `json:"type"`
|
||||
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"`
|
||||
FName string `json:"name"`
|
||||
FType string `json:"type"`
|
||||
FTime int64 `json:"time"`
|
||||
FSize int64 `json:"size"`
|
||||
FPath string `json:"path,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 {
|
||||
|
|
|
|||
|
|
@ -21,10 +21,11 @@ import (
|
|||
)
|
||||
|
||||
type FileInfo struct {
|
||||
Name string `json:"name"`
|
||||
Type string `json:"type"`
|
||||
Size int64 `json:"size"`
|
||||
Time int64 `json:"time"`
|
||||
Name string `json:"name"`
|
||||
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))
|
||||
|
|
|
|||
|
|
@ -189,10 +189,9 @@ func (this S3Backend) Ls(path string) (files []os.FileInfo, err error) {
|
|||
}
|
||||
for _, bucket := range b.Buckets {
|
||||
files = append(files, &File{
|
||||
FName: *bucket.Name,
|
||||
FType: "directory",
|
||||
FTime: bucket.CreationDate.Unix(),
|
||||
CanMove: NewBool(false),
|
||||
FName: *bucket.Name,
|
||||
FType: "directory",
|
||||
FTime: bucket.CreationDate.Unix(),
|
||||
})
|
||||
}
|
||||
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,
|
||||
FName: filepath.Base(*object.Key),
|
||||
FType: "file",
|
||||
FTime: object.LastModified.Unix(),
|
||||
FSize: size,
|
||||
Offline: isOffline,
|
||||
})
|
||||
}
|
||||
for _, object := range objs.CommonPrefixes {
|
||||
|
|
|
|||
Loading…
Reference in a new issue