database is dropped when viewing settings screen if using SD Card sync

Bug #657178 reported by Olivier Bilodeau
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Tomdroid
Fix Released
High
Olivier Bilodeau

Bug Description

Because when the preference activity loads, setServer is run for initialization and within setServer:

if (!service.needsAuth()){
    resetLocalDatabase();
}

SD Card service doesn't need auth so the database is nuked.

This is all new code to me so I'll see what I can do..

Olivier Bilodeau (plaxx)
Changed in tomdroid:
assignee: nobody → Olivier Bilodeau (plaxx)
importance: Undecided → High
milestone: none → 0.4
status: New → Confirmed
Revision history for this message
Olivier Bilodeau (plaxx) wrote :

I simply removed the lines. For SD Card it's ok and as far as I can tell it won't do any problems to Web sync... correct?

I'll make my mind on this tomorrow. It's in lp:tomdroid rev 197 for now.

I have an apk signed with debug keys if anyone's willing to test.

Revision history for this message
Rodja (trappe) wrote :

I've wrote these lines to gain a clean state when switching from Web sync to SD Card. Otherwise your Web notes will still be in the local database.

Unfortunately I overlooked that setServer(...) is not only called when the pref changes but also every time the Activity get's created:

// Enable or disable the server field depending on the selected sync service
  setServer(syncService.getValue());

  syncService.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {

   public boolean onPreferenceChange(Preference preference, Object newValue) {

    setServer((String)newValue);
    return true;
   }
  });

Revision history for this message
Rodja (trappe) wrote :

I think there are two simple solutions:

1. move the lines

if (!service.needsAuth()){
    resetLocalDatabase();
}

into the onPreferenceChangeListener

2. find an other way to enable or disable the server field depending on the selected sync service, without calling setServer() in OnCreate.

Revision history for this message
Olivier Bilodeau (plaxx) wrote :

Implemented solution 1. onPreferenceChangeListener calls a new syncServiceChanged if service changed then in here I setServer and drop database if !service.needsAuth.

Changed in tomdroid:
status: Confirmed → Fix Committed
Revision history for this message
Olivier Bilodeau (plaxx) wrote :

fix released in 0.4.0

Changed in tomdroid:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.