Skip to content

Commit

Permalink
feat: invalid symlink icon
Browse files Browse the repository at this point in the history
  • Loading branch information
ramiresviana committed May 5, 2022
1 parent 8a43413 commit b14b911
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
14 changes: 10 additions & 4 deletions files/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,14 +322,16 @@ func (i *FileInfo) readListing(checker rules.Checker, readHeader bool) error {
continue
}

isSymlink := false
isSymlink, isInvalidLink := false, false
if IsSymlink(f.Mode()) {
isSymlink = true
// It's a symbolic link. We try to follow it. If it doesn't work,
// we stay with the link information instead of the target's.
info, err := i.Fs.Stat(fPath)
if err == nil {
f = info
} else {
isInvalidLink = true
}
}

Expand All @@ -350,9 +352,13 @@ func (i *FileInfo) readListing(checker rules.Checker, readHeader bool) error {
} else {
listing.NumFiles++

err := file.detectType(true, false, readHeader)
if err != nil {
return err
if isInvalidLink {
file.Type = "invalid_link"
} else {
err := file.detectType(true, false, readHeader)
if err != nil {
return err
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/files/ListingItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export default {
methods: {
...mapMutations(["addSelected", "removeSelected", "resetSelected"]),
humanSize: function () {
return filesize(this.size);
return this.type == "invalid_link" ? "invalid link" : filesize(this.size);
},
humanTime: function () {
if (this.readOnly == undefined && this.user.dateFormat) {
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/css/listing-icons.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
.file-icons [data-type=pdf] i::before { content: 'description' }
.file-icons [data-type=text] i::before { content: 'description' }
.file-icons [data-type=video] i::before { content: 'movie' }
.file-icons [data-type=invalid_link] i::before { content: 'link_off' }

/* #f90 - Image */

Expand Down Expand Up @@ -125,6 +126,7 @@
.file-icons [data-type=audio] i { color: var(--icon-yellow) }
.file-icons [data-type=image] i { color: var(--icon-orange) }
.file-icons [data-type=video] i { color: var(--icon-violet) }
.file-icons [data-type=invalid_link] i { color: var(--icon-red) }

/* #f00 - Adobe/Oracle */

Expand Down

0 comments on commit b14b911

Please sign in to comment.