Documentation ¶
Index ¶
- Constants
- Variables
- func BasicPathResolver(pOneDriveItem *onedriveclient.OneDriveItem, pBasePathLocal string, ...) (string, error)
- func PathResolverByItemIdAndDate(pOneDriveItem *onedriveclient.OneDriveItem, pBasePathLocal string, ...) (string, error)
- type DownTheDrive
- func (vSelf *DownTheDrive) Close() error
- func (vSelf *DownTheDrive) GetApplicationInfo() (auth.ApplicationInfo, error)
- func (vSelf *DownTheDrive) GetAuthenticationToken() (*auth.AuthenticationToken, error)
- func (vSelf *DownTheDrive) GetChachedApplicationInfo() (*auth.ApplicationInfo, error)
- func (vSelf *DownTheDrive) GetDefaultContext() (*DownTheDriveContext, error)
- func (vSelf *DownTheDrive) GetItem(pItem interface{}, pExpandChilden bool, pIndexStrategy IndexStrategy, ...) (vRisItem *onedriveclient.OneDriveItem, vRisError error)
- func (vSelf *DownTheDrive) GetItemsMaxAge() time.Duration
- func (vSelf *DownTheDrive) HasItemsExpiry() bool
- func (vSelf *DownTheDrive) NewContext() (*DownTheDriveContext, error)
- func (vSelf *DownTheDrive) NewDownloader(pLocalStore *LocalStore, pWorkers int) (vRisDownloader *Downloader, vRisError error)
- func (vSelf *DownTheDrive) NewIndexer(pDriveWorkers int) (*Indexer, error)
- func (vSelf *DownTheDrive) NewItemProcessor(pOneDriveItemDispatcherFunc OneDriveItemDispatcherFunc, ...) (vRisItemProcessor *ItemProcessor, vError error)
- func (vSelf *DownTheDrive) PerformAuthentication() (vRisError error)
- func (vSelf *DownTheDrive) SaveAuthenticationInfo() error
- func (vSelf *DownTheDrive) SetAuthenticationHelper(pAuthenticationHelper auth.AuthenticationHelper)
- func (vSelf *DownTheDrive) SetDefaultIndexStrategy(pDefaultIndexStrategy IndexStrategy)
- type DownTheDriveAuthenticationConfig
- type DownTheDriveAuthenticationInfo
- type DownTheDriveConfig
- type DownTheDriveContext
- type DownTheDriveDb
- func (vSelf *DownTheDriveDb) BeginItemBulk() (vRisBeginned bool, vRisError error)
- func (vSelf *DownTheDriveDb) CommitItemBulk() error
- func (vSelf *DownTheDriveDb) EndItemBulk() error
- func (vSelf *DownTheDriveDb) GetItem(pItem interface{}, pExpandChildren bool) (vRisItem *onedriveclient.OneDriveItem, vRisError error)
- func (vSelf *DownTheDriveDb) GetItemsByConditions(pConditions string) (vRisItems []*onedriveclient.OneDriveItem, vRisError error)
- func (vSelf *DownTheDriveDb) SaveItem(pItem *onedriveclient.OneDriveItem) error
- type DownTheDriveDbConfig
- type Downloader
- type IndexStrategy
- type Indexer
- func (vSelf *Indexer) CountIndexedItems() int
- func (vSelf *Indexer) Index(pItem interface{}, pContext *DownTheDriveContext) error
- func (vSelf *Indexer) IndexDrivePath(pPath string) error
- func (vSelf *Indexer) IndexUpToRoot(pItem interface{}, pContext *DownTheDriveContext) error
- func (vSelf *Indexer) IsSucceded() bool
- func (vSelf *Indexer) StartIndexing() error
- func (vSelf *Indexer) WaitForCompletition()
- type ItemProcessor
- func (vSelf *ItemProcessor) Close() error
- func (vSelf *ItemProcessor) Enqueue(pItem interface{})
- func (vSelf *ItemProcessor) ForEachWorker(pConsumerFunc ItemProcessorWorkerConsumerFunc) error
- func (vSelf *ItemProcessor) IsSucceded() bool
- func (vSelf *ItemProcessor) Process(pItem interface{}) error
- func (vSelf *ItemProcessor) WaitForCompletition()
- type ItemProcessorWorkerConsumerFunc
- type LocalFileChecker
- type LocalFileCheckerFunc
- type LocalStore
- func (vSelf *LocalStore) Close() error
- func (vSelf *LocalStore) Exists(pOneDriveItem *onedriveclient.OneDriveItem) (bool, error)
- func (vSelf *LocalStore) Get(pOneDriveItem *onedriveclient.OneDriveItem, pContext *DownTheDriveContext) (*LocalStoreItemReference, error)
- func (vSelf *LocalStore) GetOneDriveBaseItemPath() *onedriveclient.OneDriveItem
- func (vSelf *LocalStore) Open(pItemReference *LocalStoreItemReference) (*os.File, error)
- func (vSelf *LocalStore) WriteInto(pItemReference *LocalStoreItemReference, pDestination io.Writer) error
- type LocalStoreItemReference
- type OneDriveItemDispatcherFunc
- type PathResolverFunc
Constants ¶
const ( TABLE_ITEMS = "items" FIELD_ITEMS_ID = "id" FIELD_ITEMS_PATH = "path" FIELD_ITEMS_NAME = "name" FIELD_ITEMS_PARENTID = "parent_id" FIELD_ITEMS_PARENTPATH = "parent_path" FIELD_ITEMS_SNAPSHOT_DATE = "snapshot_date" FIELD_ITEMS_CREATETIMESTAMP = "create_timestamp" FIELD_ITEMS_UPDATETIMESTAMP = "update_timestamp" FIELD_ITEMS_FOLDERCHILDREN = "folder_children" FIELD_ITEMS_SIZEBYTES = "size_bytes" FIELD_ITEMS_HASH_SHA1 = "hash_sha1" DDL_ITEMS_SQLITE = "create table if not exists " + TABLE_ITEMS + " (" + FIELD_ITEMS_ID + " text PRIMARY KEY " + "," + FIELD_ITEMS_NAME + " text " + "," + FIELD_ITEMS_SNAPSHOT_DATE + " timestamp " + "," + FIELD_ITEMS_CREATETIMESTAMP + " timestamp " + "," + FIELD_ITEMS_UPDATETIMESTAMP + " timestamp " + "," + FIELD_ITEMS_FOLDERCHILDREN + " integer " + "," + FIELD_ITEMS_SIZEBYTES + " integer " + "," + FIELD_ITEMS_PATH + " text " + "," + FIELD_ITEMS_PARENTID + " text " + "," + FIELD_ITEMS_PARENTPATH + " text" + "," + FIELD_ITEMS_HASH_SHA1 + " text" + ")" DDL_ITEMS_MYSQL = "create table if not exists " + TABLE_ITEMS + " (" + FIELD_ITEMS_ID + " varchar(700) PRIMARY KEY " + "," + FIELD_ITEMS_NAME + " varchar(1000) " + "," + FIELD_ITEMS_SNAPSHOT_DATE + " timestamp " + "," + FIELD_ITEMS_CREATETIMESTAMP + " timestamp " + "," + FIELD_ITEMS_UPDATETIMESTAMP + " timestamp " + "," + FIELD_ITEMS_FOLDERCHILDREN + " integer " + "," + FIELD_ITEMS_SIZEBYTES + " integer " + "," + FIELD_ITEMS_PATH + " varchar(10000) " + "," + FIELD_ITEMS_PARENTID + " varchar(700) " + "," + FIELD_ITEMS_PARENTPATH + " varchar(10000) " + "," + FIELD_ITEMS_HASH_SHA1 + " varchar(200) " + ")" )
const ( IndexStrategy_IndexOrDrive IndexStrategy = 0 IndexStrategy_IndexOnly IndexStrategy = iota IndexStrategy_DriveOnly IndexStrategy = iota IndexStrategy_Default IndexStrategy = iota ItemsMaxAge_None time.Duration = -1 ItemsMaxAge_Unspecified time.Duration = 0 ItemsMaxAge_Default time.Duration = time.Hour * 24 * 15 )
Variables ¶
var (
FIELDS_ITEMS = []string{FIELD_ITEMS_ID, FIELD_ITEMS_NAME, FIELD_ITEMS_FOLDERCHILDREN, FIELD_ITEMS_SNAPSHOT_DATE, FIELD_ITEMS_CREATETIMESTAMP, FIELD_ITEMS_UPDATETIMESTAMP, FIELD_ITEMS_PATH, FIELD_ITEMS_PARENTID, FIELD_ITEMS_PARENTPATH, FIELD_ITEMS_SIZEBYTES, FIELD_ITEMS_HASH_SHA1}
)
Functions ¶
func BasicPathResolver ¶
func BasicPathResolver(pOneDriveItem *onedriveclient.OneDriveItem, pBasePathLocal string, pBasePathDrive string) (string, error)
BasicPathResolver file maintains the same path locally
func PathResolverByItemIdAndDate ¶
func PathResolverByItemIdAndDate(pOneDriveItem *onedriveclient.OneDriveItem, pBasePathLocal string, pBasePathDrive string) (string, error)
PathResolverByItemIdAndDate store files locally by item id and date (for a very basic versioning)
Types ¶
type DownTheDrive ¶
type DownTheDrive struct { DenySynchronousAuthentication bool // contains filtered or unexported fields }
DownTheDrive: onedrive utiliy to index the drive into a database and access the content
func NewDownTheDrive ¶
func NewDownTheDrive(pConfig DownTheDriveConfig) (*DownTheDrive, error)
NewDownTheDrive: create a new instance of downthedrive Parameters:
DownTheDriveConfig = configuration
Returns:
*DownTheDrive = DownTheDrive instance error = nil if succeded otherwise the error occurred
func (*DownTheDrive) Close ¶
func (vSelf *DownTheDrive) Close() error
func (*DownTheDrive) GetApplicationInfo ¶
func (vSelf *DownTheDrive) GetApplicationInfo() (auth.ApplicationInfo, error)
func (*DownTheDrive) GetAuthenticationToken ¶
func (vSelf *DownTheDrive) GetAuthenticationToken() (*auth.AuthenticationToken, error)
func (*DownTheDrive) GetChachedApplicationInfo ¶
func (vSelf *DownTheDrive) GetChachedApplicationInfo() (*auth.ApplicationInfo, error)
func (*DownTheDrive) GetDefaultContext ¶
func (vSelf *DownTheDrive) GetDefaultContext() (*DownTheDriveContext, error)
GetDefaultContext: return a context
func (*DownTheDrive) GetItem ¶
func (vSelf *DownTheDrive) GetItem(pItem interface{}, pExpandChilden bool, pIndexStrategy IndexStrategy, pContext *DownTheDriveContext) (vRisItem *onedriveclient.OneDriveItem, vRisError error)
func (*DownTheDrive) GetItemsMaxAge ¶
func (vSelf *DownTheDrive) GetItemsMaxAge() time.Duration
func (*DownTheDrive) HasItemsExpiry ¶
func (vSelf *DownTheDrive) HasItemsExpiry() bool
func (*DownTheDrive) NewContext ¶
func (vSelf *DownTheDrive) NewContext() (*DownTheDriveContext, error)
NewContext: return a new context
func (*DownTheDrive) NewDownloader ¶
func (vSelf *DownTheDrive) NewDownloader(pLocalStore *LocalStore, pWorkers int) (vRisDownloader *Downloader, vRisError error)
NewDownLoader: create a new instance of downloader Parameters: pDrivePath = path on the drive to download ( "/" = root of the drive) pLocalPath = local path where to downlaod item contents pWorkers = number of concurrent workers Returns: *Downloader = instance of the downloader error = nil if succeded otherwise the error
func (*DownTheDrive) NewIndexer ¶
func (vSelf *DownTheDrive) NewIndexer(pDriveWorkers int) (*Indexer, error)
NewIndexer: create a new instance of indexer Parameters:
pDriveWorkers = number of concurrent workers to the drive
Returns:
*Indexer = indexer object error = nil if succeded otherwise the error occurred
func (*DownTheDrive) NewItemProcessor ¶
func (vSelf *DownTheDrive) NewItemProcessor(pOneDriveItemDispatcherFunc OneDriveItemDispatcherFunc, pIndexStategy IndexStrategy, pWorkers int) (vRisItemProcessor *ItemProcessor, vError error)
NewItemProcessor create a new instance of item processor
func (*DownTheDrive) PerformAuthentication ¶
func (vSelf *DownTheDrive) PerformAuthentication() (vRisError error)
func (*DownTheDrive) SaveAuthenticationInfo ¶
func (vSelf *DownTheDrive) SaveAuthenticationInfo() error
func (*DownTheDrive) SetAuthenticationHelper ¶
func (vSelf *DownTheDrive) SetAuthenticationHelper(pAuthenticationHelper auth.AuthenticationHelper)
func (*DownTheDrive) SetDefaultIndexStrategy ¶
func (vSelf *DownTheDrive) SetDefaultIndexStrategy(pDefaultIndexStrategy IndexStrategy)
type DownTheDriveAuthenticationInfo ¶
type DownTheDriveAuthenticationInfo struct {
auth.StaticAuthenticationInfo
}
func (*DownTheDriveAuthenticationInfo) GetIdInDb ¶
func (vSelf *DownTheDriveAuthenticationInfo) GetIdInDb() string
type DownTheDriveConfig ¶
type DownTheDriveConfig struct { Authentication DownTheDriveAuthenticationConfig Db DownTheDriveDbConfig IndexStrategy IndexStrategy ItemsMaxAge time.Duration }
type DownTheDriveContext ¶
type DownTheDriveContext struct {
// contains filtered or unexported fields
}
DownTheDriveContext: holder for all the local objects needed by downthedrive
func (*DownTheDriveContext) Close ¶
func (vSelf *DownTheDriveContext) Close() error
func (*DownTheDriveContext) GetDb ¶
func (vSelf *DownTheDriveContext) GetDb() (*DownTheDriveDb, error)
GetDb: return a db object instance for the current context
func (*DownTheDriveContext) GetOneDriveClient ¶
func (vSelf *DownTheDriveContext) GetOneDriveClient() (*onedriveclient.OneDriveClient, error)
GetOneDriveClient: return a onedrive object instance for the current context
type DownTheDriveDb ¶
func NewDb ¶
func NewDb(pDriver string, pDataSourceName string) (vRisIndexDb *DownTheDriveDb, vError error)
func (*DownTheDriveDb) BeginItemBulk ¶
func (vSelf *DownTheDriveDb) BeginItemBulk() (vRisBeginned bool, vRisError error)
func (*DownTheDriveDb) CommitItemBulk ¶
func (vSelf *DownTheDriveDb) CommitItemBulk() error
func (*DownTheDriveDb) EndItemBulk ¶
func (vSelf *DownTheDriveDb) EndItemBulk() error
func (*DownTheDriveDb) GetItem ¶
func (vSelf *DownTheDriveDb) GetItem(pItem interface{}, pExpandChildren bool) (vRisItem *onedriveclient.OneDriveItem, vRisError error)
func (*DownTheDriveDb) GetItemsByConditions ¶
func (vSelf *DownTheDriveDb) GetItemsByConditions(pConditions string) (vRisItems []*onedriveclient.OneDriveItem, vRisError error)
func (*DownTheDriveDb) SaveItem ¶
func (vSelf *DownTheDriveDb) SaveItem(pItem *onedriveclient.OneDriveItem) error
type DownTheDriveDbConfig ¶
type Downloader ¶
type Downloader struct {
// contains filtered or unexported fields
}
Downloader: allows to download items content from drive
func (*Downloader) Close ¶
func (vSelf *Downloader) Close() error
func (*Downloader) Download ¶
func (vSelf *Downloader) Download() error
type IndexStrategy ¶
type IndexStrategy int
type Indexer ¶
type Indexer struct {
// contains filtered or unexported fields
}
Indexed: allows to index onedrive path into a database
func (*Indexer) CountIndexedItems ¶
func (*Indexer) Index ¶
func (vSelf *Indexer) Index(pItem interface{}, pContext *DownTheDriveContext) error
Index: index a single item into the database Parameters:
pItem = item to index pContext = instance of DownTheDriveContext
Returns:
error = nil if succeded otherwise the error
func (*Indexer) IndexDrivePath ¶
Build: index a drive path Parameters:
pPath = drive path to index
Returns:
nil if succeded otherwise the error
func (*Indexer) IndexUpToRoot ¶
func (vSelf *Indexer) IndexUpToRoot(pItem interface{}, pContext *DownTheDriveContext) error
IndexUpToRoot: index an item and parents up to root Parameters:
pItem = item to index pContext = instance of DownTheDriveContext
Returns:
nil if succeded otherwise the error
func (*Indexer) IsSucceded ¶
func (*Indexer) StartIndexing ¶
func (*Indexer) WaitForCompletition ¶
func (vSelf *Indexer) WaitForCompletition()
type ItemProcessor ¶
type ItemProcessor struct { //parent Parent *DownTheDrive // contains filtered or unexported fields }
ItemProcessor is an object for item recurring operations
func (*ItemProcessor) Close ¶
func (vSelf *ItemProcessor) Close() error
func (*ItemProcessor) Enqueue ¶
func (vSelf *ItemProcessor) Enqueue(pItem interface{})
Enqueue an item Parameters: pItem = item to process
func (*ItemProcessor) ForEachWorker ¶
func (vSelf *ItemProcessor) ForEachWorker(pConsumerFunc ItemProcessorWorkerConsumerFunc) error
func (*ItemProcessor) IsSucceded ¶
func (vSelf *ItemProcessor) IsSucceded() bool
func (*ItemProcessor) Process ¶
func (vSelf *ItemProcessor) Process(pItem interface{}) error
func (*ItemProcessor) WaitForCompletition ¶
func (vSelf *ItemProcessor) WaitForCompletition()
type ItemProcessorWorkerConsumerFunc ¶
type ItemProcessorWorkerConsumerFunc func(pContext *DownTheDriveContext, pWorkerId int) error
type LocalFileChecker ¶
func (*LocalFileChecker) CheckerFunc ¶
func (vSelf *LocalFileChecker) CheckerFunc(pOneDriveItem *onedriveclient.OneDriveItem, pLocalFilePath string) (bool, error)
type LocalFileCheckerFunc ¶
type LocalFileCheckerFunc func(pOneDriveItem *onedriveclient.OneDriveItem, pLocalFilePath string) (bool, error)
LocalFileCheckerFunc: function to check if a onedriveitem and a local file have the same content Parameters:
OneDriveItem = One Drive Item string = local file path
Returns:
bool=true if local file exists and is the same of remote file, otherwise false error=error if something goes wrong
type LocalStore ¶
type LocalStore struct { LocalFileCheckerFunc LocalFileCheckerFunc // contains filtered or unexported fields }
LocalStore: manager of locally stored files
func NewLocalStore ¶
func NewLocalStore(pBasePathLocal string, pOneDriveBaseItemPath *onedriveclient.OneDriveItem, pPathResolverFunc PathResolverFunc) (*LocalStore, error)
NewLocalStore: create a new local store
func (*LocalStore) Close ¶
func (vSelf *LocalStore) Close() error
func (*LocalStore) Exists ¶
func (vSelf *LocalStore) Exists(pOneDriveItem *onedriveclient.OneDriveItem) (bool, error)
func (*LocalStore) Get ¶
func (vSelf *LocalStore) Get(pOneDriveItem *onedriveclient.OneDriveItem, pContext *DownTheDriveContext) (*LocalStoreItemReference, error)
Get: store locally the content of the specified onedriveitem if not present then return a refrence Parameters:
pOneDriveItem = item to store pDownTheDriveContext = DownTheDrive context
Return:
LocalStoreItemReference = a reference to open the file error = nil if succeded otherwise the error
func (*LocalStore) GetOneDriveBaseItemPath ¶
func (vSelf *LocalStore) GetOneDriveBaseItemPath() *onedriveclient.OneDriveItem
func (*LocalStore) Open ¶
func (vSelf *LocalStore) Open(pItemReference *LocalStoreItemReference) (*os.File, error)
Open: open the file Parameters:
*LocalStoreItemReference = item reference
Returns:
*os.File = local file error = nil if succeded otherwise the error
func (*LocalStore) WriteInto ¶
func (vSelf *LocalStore) WriteInto(pItemReference *LocalStoreItemReference, pDestination io.Writer) error
WriteInto write the content of the item into a writer Parameters:
*LocalStoreItemReference = item reference io.Writer = Destination
Returns: nil if succeded otherwise the error
type LocalStoreItemReference ¶
type LocalStoreItemReference struct {
// contains filtered or unexported fields
}
LocalStoreItemReference: reference to an item stored locally
type OneDriveItemDispatcherFunc ¶
type OneDriveItemDispatcherFunc func(pContext *DownTheDriveContext, pItem *onedriveclient.OneDriveItem, pWorkerId int) error
OneDriveItemDispatcherFunc signature of dispatcher method Parameters:
pContext = DownTheDrive context pItem = item to process pWorkerId = id of the current worker
Returns:
nil in case of success otherwise the error
type PathResolverFunc ¶
type PathResolverFunc func(*onedriveclient.OneDriveItem, string, string) (string, error)
PathResolverFunc function responsible to translate item to local path Parameters:
*onedriveclient.OneDriveItem = one drive item string = local base path string = base drive path
Returns:
string = path of the drive item locally, empty in the item is not stored locally error = nil if succeded, otherwise the error occurred