fs: fix bug picking recent filenames when file has no name

e.g. iphone uploads

Change-Id: Ieee398b6f43c261232bc9f6cc0c71cb97c5c49f8
This commit is contained in:
Brad Fitzpatrick 2014-02-02 06:14:44 +01:00
parent 53203f09b5
commit 433a312703
1 changed files with 7 additions and 2 deletions

View File

@ -21,7 +21,8 @@ package fs
import ( import (
"log" "log"
"os" "os"
"path" "path/filepath"
"strings"
"sync" "sync"
"time" "time"
@ -109,7 +110,11 @@ func (n *recentDir) ReadDir(intr fs.Intr) ([]fuse.Dirent, fuse.Error) {
continue continue
} }
if name == "" || n.ents[name] != nil { if name == "" || n.ents[name] != nil {
name = ccMeta.BlobRef.String() + path.Ext(name) ext := filepath.Ext(name)
if ext == "" && strings.HasSuffix(ccMeta.File.MIMEType, "image/jpeg") {
ext = ".jpg"
}
name = strings.TrimPrefix(ccMeta.BlobRef.String(), "sha1-")[:10] + ext
if n.ents[name] != nil { if n.ents[name] != nil {
continue continue
} }