Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Prune legacy data from Cliqz browser (#371)

  • Loading branch information
sammacbeth authored and naira-cliqz committed Jun 28, 2019
1 parent a69bc22 commit 66948568dc50e5855143db78a98107f5309e2d6d
Showing with 16 additions and 1 deletion.
  1. +16 −1 cliqz.js
@@ -2,12 +2,27 @@ import 'react-native/Libraries/Core/InitializeCore';
import './setup';
import 'process-nextick-args';
import React from 'react';
import { AppRegistry, StyleSheet, View } from 'react-native';
import { AppRegistry, StyleSheet, View, AsyncStorage } from 'react-native';
import { startup, components } from 'browser-core-cliqz-ios';

async function cleanUpStorage() {
const migrateKey = '@migrated';
const migrateVersion = '1';
const migrated = await AsyncStorage.getItem(migrateKey);
if (migrated !== migrateVersion) {
console.log('Migrate legacy storage');
const keys = await AsyncStorage.getAllKeys();
// prune legacy fs and anti-tracking storage namespaces
const pruneKeys = keys.filter(k => k.startsWith('@fs:') || k.startsWith('@cliqzstorage'));
await AsyncStorage.multiRemove(pruneKeys);
await AsyncStorage.setItem(migrateKey, migrateVersion);
}
}

// set app global for debugging
const appStart = startup.then((app) => {
global.app = app;
cleanUpStorage();
});

const styles = StyleSheet.create({

0 comments on commit 6694856

Please sign in to comment.