From 7e2e07da8cc7985e773e619410801c6dd84afe8b Mon Sep 17 00:00:00 2001 From: Jeff Halter <868228+jhalter@users.noreply.github.com> Date: Sun, 29 May 2022 10:03:19 -0700 Subject: Implement handling of special case Dropbox and Upload folders --- hotline/file_path.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'hotline/file_path.go') diff --git a/hotline/file_path.go b/hotline/file_path.go index 2e2e085..d5ddd23 100644 --- a/hotline/file_path.go +++ b/hotline/file_path.go @@ -5,6 +5,7 @@ import ( "encoding/binary" "errors" "path" + "strings" ) const pathSeparator = "/" // File path separator TODO: make configurable to support Windows @@ -31,6 +32,7 @@ type FilePath struct { } const minFilePathLen = 2 + func (fp *FilePath) UnmarshalBinary(b []byte) error { if b == nil { return nil @@ -53,6 +55,22 @@ func (fp *FilePath) UnmarshalBinary(b []byte) error { return nil } +func (fp *FilePath) IsDropbox() bool { + if fp.Len() == 0 { + return false + } + + return strings.Contains(strings.ToLower(string(fp.Items[fp.Len()-1].Name)), "drop box") +} + +func (fp *FilePath) IsUploadDir() bool { + if fp.Len() == 0 { + return false + } + + return strings.Contains(strings.ToLower(string(fp.Items[fp.Len()-1].Name)), "uploads") +} + func (fp *FilePath) Len() uint16 { return binary.BigEndian.Uint16(fp.ItemCount[:]) } -- cgit