1

In my app, using PyDrive and Google Drive, a file is created by user A, saved onto Drive using

self.User.GoogleFile.SetContentString(json.dumps(self.Message))

and the file is shared with user B. When userB reads the file using

self.Message=json.loads(self.User.GoogleFile.GetContentString())

the message contains the correct data. If self.Message is modified by user A, and saved using

self.User.GoogleFile.SetContentString(json.dumps(self.Message))

then, if user B reads the file again, self.Message just contains the original data and not the updated value

Is there any way to refresh the file, or clear the cache, or any command I should run to get user B to get the up to date data?

Psionman
  • 3,084
  • 1
  • 32
  • 65

1 Answers1

1

I now realise that you need to refresh the instance of the Google file list.

I was doing this

drivefiles  = drive.ListFile().GetList()
self.User.GoogleFile = None
while True:    
    for f in drivefiles:
        if f['title'] == 'Hello.txt':
            self.User.GoogleFile = f
            break
        if self.User.GoogleFile!=None:
            self.Message=json.loads(self.User.GoogleFile.GetContentString())
    raw_input("Press Enter to continue...")

when I needed to do this

while True:    
    drivefiles  = drive.ListFile().GetList()
    self.User.GoogleFile = None
    for f in drivefiles:
        if f['title'] == 'Hello.txt':
            self.User.GoogleFile = f
            break
        if self.User.GoogleFile!=None:
            self.Message=json.loads(self.User.GoogleFile.GetContentString())
    raw_input("Press Enter to continue...")
Psionman
  • 3,084
  • 1
  • 32
  • 65