MCPcopy Index your code
hub / github.com/plexdrive/plexdrive / checkChanges

Method checkChanges

drive/drive.go:98–215  ·  view source on GitHub ↗
(firstCheck bool)

Source from the content-addressed store, hash-verified

96}
97
98func (d *Client) checkChanges(firstCheck bool) {
99 d.lock.Lock()
100 if d.changesChecking {
101 return
102 }
103 d.changesChecking = true
104 d.lock.Unlock()
105 defer func() {
106 d.lock.Lock()
107 d.changesChecking = false
108 d.lock.Unlock()
109 }()
110
111 Log.Debugf("Checking for changes")
112
113 client, err := d.getClient()
114 if nil != err {
115 Log.Debugf("%v", err)
116 Log.Warningf("Could not get Google Drive client to watch for changes")
117 return
118 }
119
120 // get the last token
121 pageToken, err := d.cache.GetStartPageToken()
122 if nil != err {
123 pageToken = "1"
124 Log.Info("No last change id found, starting from beginning...")
125 } else {
126 Log.Debugf("Last change id found, continuing getting changes (%v)", pageToken)
127 }
128
129 if firstCheck {
130 Log.Infof("First cache build process started...")
131 }
132
133 deletedItems := 0
134 updatedItems := 0
135 processedItems := 0
136 for {
137 query := client.Changes.
138 List(pageToken).
139 Fields(googleapi.Field(fmt.Sprintf("nextPageToken, newStartPageToken, changes(changeType, removed, fileId, file(%v))", fields))).
140 PageSize(1000).
141 SupportsAllDrives(true).
142 IncludeItemsFromAllDrives(true).
143 IncludeCorpusRemovals(true)
144
145 if d.driveID != "" {
146 query = query.DriveId(d.driveID)
147 }
148
149 results, err := query.Do()
150 if nil != err {
151 Log.Debugf("%v", err)
152 Log.Warningf("Could not get changes")
153 break
154 }
155

Callers 1

startWatchChangesMethod · 0.95

Calls 6

getClientMethod · 0.95
mapFileToObjectMethod · 0.95
GetStartPageTokenMethod · 0.80
DeleteObjectMethod · 0.80
BatchUpdateObjectsMethod · 0.80
StoreStartPageTokenMethod · 0.80

Tested by

no test coverage detected