hotfix for duplicates and artefacts
authorHannes Domschke <redacted>
Sun, 15 Nov 2015 21:38:07 +0000 (22:38 +0100)
committerHannes Domschke <redacted>
Sun, 15 Nov 2015 21:38:07 +0000 (22:38 +0100)
updateHostsFile.py

index ea5a5130f2b48d34e2ef375259ded3d96034b59a..8047d734ec07eb147cd5754f8cd2a727b8f16c5e 100755 (executable)
@@ -90,6 +90,7 @@ exclusionRegexs = []
 numberOfRules = 0
 
 def main():
+       removeOldHostsFile()
        promptForUpdate()
        promptForExclusions()
        mergeFile = createInitialFile()
@@ -313,6 +314,12 @@ def moveHostsFileIntoPlace(finalFile):
        elif (os.name == 'nt'):
                print ('Automatically moving the hosts file in place is not yet supported.')
                print ('Please move the generated file to %SystemRoot%\system32\drivers\etc\hosts')
+               
+def removeOldHostsFile():                      # hotfix since merging with an already existing hosts file leads to artefacts and duplicates
+       oldFilePath=os.path.join(BASEDIR_PATH,'hosts')
+       open(oldFilePath, 'a').close()          # create if already removed, so remove wont raise an error
+       os.remove(oldFilePath);
+       open(oldFilePath, 'a').close()          # create new empty hostsfile
 
 # End File Logic
 
git clone https://git.99rst.org/PROJECT