mCleaner.Logics.Commands.CommandLogic_Chrome.CleanFavIcons C# (CSharp) Method

CleanFavIcons() public static method

public static CleanFavIcons ( string file ) : string
file string
return string
        public static string CleanFavIcons(string file)
        {
            string ret = string.Empty;

            string history_db = Path.Combine(ChromeDefaultPath, "History");
            string sql = string.Empty;
            string where = string.Empty;

            sql = string.Format("attach database \"{0}\" as History;", history_db);

            // icon mapping
            string[] cols = new string[] {
                "page_url"
            };
            where = "where page_url not in (select distinct url from History.urls)";
            if (Shred)
            {
                sql += CreateRandomBlobQuery(cols, "icon_mapping", where);
            }
            sql += string.Format("delete from icon_mapping {0};", where);

            // favicon images
            cols = new string[] {
                "image_data"
            };
            where = "where id not in (select distinct id from icon_mapping)";
            if (Shred)
            {
                sql += CreateRandomBlobQuery(cols, "favicon_bitmaps", where);
            }
            sql += string.Format("delete from favicon_bitmaps {0};", where);

            ChromeCurrentVersion = ChromeVersion();

            // favicon bitmaps
            if (ChromeCurrentVersion < 28)
            {
                cols = new string[] { "url", "image_data" };
            }
            else
            {
                cols = new string[] { "url" };
            }
            where = "where id not in (select distinct icon_id from icon_mapping)";
            if (Shred)
            {
                sql += CreateRandomBlobQuery(cols, "favicons", where);
            }
            sql += string.Format("delete from favicons {0};", where);

            string result = SQLite.ExecuteNonQuery(file, sql);

            if (result != string.Empty)
            {
                ret = "An unkown error occured while executing a query in CommandLogic_Chrome.CleanAutofill";

                if (result.Contains("database is locked"))
                {
                    ret = "database is locked";
                }
            }

            return ret;
        }