Beispiel #1
0
def guess_overwrite_paths():
    """Guess which partitions to overwrite (to hide deleted files)"""
    # In case overwriting leaves large files, placing them in
    # ~/.config makes it easy to find them and clean them.
    ret = []
    if 'posix' == os.name:
        home = expanduser('~/.cache')
        if not os.path.exists(home):
            home = expanduser("~")
        ret.append(home)
        if not same_partition(home, '/tmp/'):
            ret.append('/tmp')
    elif 'nt' == os.name:
        localtmp = bleachbit.expandvars('$TMP')
        if not os.path.exists(localtmp):
            logger.warning('%TMP% does not exist: %s', localtmp)
            localtmp = None
        from bleachbit.Windows import get_fixed_drives
        for drive in get_fixed_drives():
            if localtmp and same_partition(localtmp, drive):
                ret.append(localtmp)
            else:
                ret.append(drive)
    else:
        NotImplementedError('Unsupported OS in guess_overwrite_paths')
    return ret
Beispiel #2
0
def guess_overwrite_paths():
    """Guess which partitions to overwrite (to hide deleted files)"""
    # In case overwriting leaves large files, placing them in
    # ~/.config makes it easy to find them and clean them.
    ret = []
    if 'posix' == os.name:
        home = os.path.expanduser('~/.cache')
        if not os.path.exists(home):
            home = os.path.expanduser("~")
        ret.append(home)
        if not same_partition(home, '/tmp/'):
            ret.append('/tmp')
    elif 'nt' == os.name:
        localtmp = os.path.expandvars('$TMP')
        if not os.path.exists(localtmp):
            logger.warning(
                _("The environment variable TMP refers to a directory that does not exist: %s"
                  ), localtmp)
            localtmp = None
        from bleachbit.Windows import get_fixed_drives
        for drive in get_fixed_drives():
            if localtmp and same_partition(localtmp, drive):
                ret.append(localtmp)
            else:
                ret.append(drive)
    else:
        raise NotImplementedError('Unsupported OS in guess_overwrite_paths')
    return ret
 def test_same_partition(self):
     """Unit test for same_partition()"""
     home = expanduser('~')
     self.assertTrue(same_partition(home, home))
     if 'posix' == os.name:
         self.assertFalse(same_partition(home, '/dev'))
     if 'nt' == os.name:
         home_drive = os.path.splitdrive(home)[0]
         from bleachbit.Windows import get_fixed_drives
         for drive in get_fixed_drives():
             this_drive = os.path.splitdrive(drive)[0]
             self.assertEqual(same_partition(home, drive), home_drive == this_drive)
 def test_same_partition(self):
     """Unit test for same_partition()"""
     home = expanduser('~')
     self.assertTrue(same_partition(home, home))
     if 'posix' == os.name:
         self.assertFalse(same_partition(home, '/dev'))
     if 'nt' == os.name:
         home_drive = os.path.splitdrive(home)[0]
         from bleachbit.Windows import get_fixed_drives
         for drive in get_fixed_drives():
             this_drive = os.path.splitdrive(drive)[0]
             self.assertEqual(same_partition(home, drive), home_drive == this_drive)