Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b407f22c authored by Christopher Tate's avatar Christopher Tate
Browse files

Don't invoke the transport if doBackup supplied no data

If there's no data to be backed up, we no longer invoke the transport.  We *DO*
still require that the agent have emitted a valid new state file, however.

This change also finally uncomments the code that removes the backup data file
after it has been sent to the transport, so there will be no more
packagename.data files lying around in the staging area.
parent f9c228a5
Loading
Loading
Loading
Loading
+17 −9
Original line number Diff line number Diff line
@@ -810,17 +810,25 @@ class BackupManagerService extends IBackupManager.Stub {

                // Now propagate the newly-backed-up data to the transport
                if (success) {
                    if (DEBUG) Log.v(TAG, "doBackup() success; calling transport");
                    if (DEBUG) Log.v(TAG, "doBackup() success");
                    if (backupDataName.length() > 0) {
                        backupData =
                        ParcelFileDescriptor.open(backupDataName, ParcelFileDescriptor.MODE_READ_ONLY);
                            ParcelFileDescriptor.open(backupDataName,
                                    ParcelFileDescriptor.MODE_READ_ONLY);
                        if (!transport.performBackup(packInfo, backupData)) {
                            // STOPSHIP TODO: handle errors
                            Log.e(TAG, "Backup failure in performBackup()");
                        }
                    } else {
                        if (DEBUG) {
                            Log.i(TAG, "no backup data written; not calling transport");
                        }
                    }

                    // !!! TODO: After successful transport, delete the now-stale data
                    // and juggle the files so that next time the new state is passed
                    //backupDataName.delete();
                    // After successful transport, delete the now-stale data
                    // and juggle the files so that next time we supply the agent
                    // with the new state file it just created.
                    backupDataName.delete();
                    newStateName.renameTo(savedStateName);
                }
            } catch (Exception e) {