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

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

Properly set up local transport data dirs after an initialize operation

We were properly setting up the underlying storage at boot time, but
*not* doing so after an "initialize" operation, i.e. after wiping all
of the data upon request.  The effect was that after an init operation
while using the local transport (e.g. if you disabled backup and then
reenabled it with the local transport as your active one), full-data
backup operations wouldn't work until after the next reboot.

Change-Id: I3bfda1e94ae2312678b0bb2dde13ebdb64a56d2b
parent d58617b4
Loading
Loading
Loading
Loading
+9 −7
Original line number Original line Diff line number Diff line
@@ -84,7 +84,6 @@ public class LocalTransport extends BackupTransport {
    private File mRestoreSetDir;
    private File mRestoreSetDir;
    private File mRestoreSetIncrementalDir;
    private File mRestoreSetIncrementalDir;
    private File mRestoreSetFullDir;
    private File mRestoreSetFullDir;
    private long mRestoreToken;


    // Additional bookkeeping for full backup
    // Additional bookkeeping for full backup
    private String mFullTargetPackage;
    private String mFullTargetPackage;
@@ -93,20 +92,22 @@ public class LocalTransport extends BackupTransport {
    private BufferedOutputStream mFullBackupOutputStream;
    private BufferedOutputStream mFullBackupOutputStream;
    private byte[] mFullBackupBuffer;
    private byte[] mFullBackupBuffer;


    private File mFullRestoreSetDir;
    private HashSet<String> mFullRestorePackages;
    private FileInputStream mCurFullRestoreStream;
    private FileInputStream mCurFullRestoreStream;
    private FileOutputStream mFullRestoreSocketStream;
    private FileOutputStream mFullRestoreSocketStream;
    private byte[] mFullRestoreBuffer;
    private byte[] mFullRestoreBuffer;


    public LocalTransport(Context context) {
    private void makeDataDirs() {
        mContext = context;
        mCurrentSetDir.mkdirs();
        mCurrentSetDir.mkdirs();
        mCurrentSetFullDir.mkdir();
        mCurrentSetIncrementalDir.mkdir();
        if (!SELinux.restorecon(mCurrentSetDir)) {
        if (!SELinux.restorecon(mCurrentSetDir)) {
            Log.e(TAG, "SELinux restorecon failed for " + mCurrentSetDir);
            Log.e(TAG, "SELinux restorecon failed for " + mCurrentSetDir);
        }
        }
        mCurrentSetFullDir.mkdir();
        mCurrentSetIncrementalDir.mkdir();
    }

    public LocalTransport(Context context) {
        mContext = context;
        makeDataDirs();
    }
    }


    @Override
    @Override
@@ -151,6 +152,7 @@ public class LocalTransport extends BackupTransport {
    public int initializeDevice() {
    public int initializeDevice() {
        if (DEBUG) Log.v(TAG, "wiping all data");
        if (DEBUG) Log.v(TAG, "wiping all data");
        deleteContents(mCurrentSetDir);
        deleteContents(mCurrentSetDir);
        makeDataDirs();
        return TRANSPORT_OK;
        return TRANSPORT_OK;
    }
    }