mirror of https://github.com/perkeep/perkeep.git
Mark boring files generated by FUSE as "hidden", then hide in the UI.
Makes for prettier FUSE demos w/ files showing up live in the browser with websockets. Change-Id: I41cc9ae0d33db39b4dbbf5b60714cee9a79b7248
This commit is contained in:
parent
617bbf5295
commit
9af5a970de
|
@ -271,6 +271,12 @@ func (n *mutDir) Symlink(req *fuse.SymlinkRequest, intr fuse.Intr) (fuse.Node, f
|
|||
return node, nil
|
||||
}
|
||||
|
||||
func stupidMacExtendedAttributeName(name string) bool {
|
||||
// TODO: if we supported extended attributes, the OS X finder wouldn't
|
||||
// generate these files anyway.
|
||||
return strings.HasPrefix(name, "._") || name == ".DS_Store"
|
||||
}
|
||||
|
||||
func (n *mutDir) creat(name string, typ nodeType) (fuse.Node, error) {
|
||||
// Create a Permanode for the file/directory.
|
||||
pr, err := n.fs.client.UploadNewPermanode()
|
||||
|
@ -278,10 +284,22 @@ func (n *mutDir) creat(name string, typ nodeType) (fuse.Node, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
// Add a camliPath:name attribute to the directory permanode.
|
||||
claim := schema.NewSetAttributeClaim(n.permanode, "camliPath:"+name, pr.BlobRef.String())
|
||||
_, err = n.fs.client.UploadAndSignBlob(claim)
|
||||
if err != nil {
|
||||
var grp syncutil.Group
|
||||
grp.Go(func() (err error) {
|
||||
// Add a camliPath:name attribute to the directory permanode.
|
||||
claim := schema.NewSetAttributeClaim(n.permanode, "camliPath:"+name, pr.BlobRef.String())
|
||||
_, err = n.fs.client.UploadAndSignBlob(claim)
|
||||
return
|
||||
})
|
||||
if stupidMacExtendedAttributeName(name) {
|
||||
grp.Go(func() (err error) {
|
||||
// Add a camliPath:name attribute to the directory permanode.
|
||||
claim := schema.NewSetAttributeClaim(pr.BlobRef, "camliDefVis", "hide")
|
||||
_, err = n.fs.client.UploadAndSignBlob(claim)
|
||||
return
|
||||
})
|
||||
}
|
||||
if err := grp.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
|
|
@ -322,6 +322,9 @@ type PermanodeConstraint struct {
|
|||
// This is required if any of the items below are used.
|
||||
Attr string `json:"attr"`
|
||||
|
||||
// SkipHidden skips hidden or other boring files.
|
||||
SkipHidden bool `json:"skipHidden"`
|
||||
|
||||
// NumValue optionally tests the number of values this
|
||||
// permanode has for Attr.
|
||||
NumValue *IntConstraint `json:"numValue"`
|
||||
|
@ -713,6 +716,16 @@ func (c *PermanodeConstraint) blobMatches(s *search, br blob.Ref, bm camtypes.Bl
|
|||
return false, err
|
||||
}
|
||||
}
|
||||
|
||||
if c.SkipHidden && corpus != nil {
|
||||
vals := corpus.AppendPermanodeAttrValuesLocked(s.ss[:0], br, "camliDefVis", time.Time{}, s.h.owner)
|
||||
for _, v := range vals {
|
||||
if v == "hide" {
|
||||
return false, nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if c.ModTime != nil {
|
||||
if corpus != nil {
|
||||
mt, ok := corpus.PermanodeModtimeLocked(br)
|
||||
|
|
|
@ -307,7 +307,9 @@ camlistore.BlobItemContainer.prototype.exitDocument = function() {
|
|||
*/
|
||||
camlistore.BlobItemContainer.prototype.showRecent = function() {
|
||||
this.search({
|
||||
camliType: 'permanode'
|
||||
permanode: {
|
||||
skipHidden: true
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue