Delete @tmp/artifactory-pipeline-cache/build-number directories older than 1 day.
762921
static void deleteOldBuildDataDirs(File tmpDir, Log logger) {
        if (!tmpDir.exists()) {
            // Before creation of the @tmp directory
            return;
        }
        File[] buildDataDirs = tmpDir.listFiles(buildDataDir -> {
            long ageInMilliseconds = new Date().getTime() - buildDataDir.lastModified();
            return ageInMilliseconds > TimeUnit.DAYS.toMillis(1);
        });
        if (buildDataDirs == null) {
            logger.error("Failed while attempting to delete old build data dirs. Could not list files in " + tmpDir);
            return;
        }

        for (File buildDataDir : buildDataDirs) {
            try {
                FileUtils.deleteDirectory(buildDataDir);
                logger.debug(buildDataDir.getAbsolutePath() + " deleted");
            } catch (IOException e) {
                logger.error("Failed while attempting to delete old build data dir: " + buildDataDir.toString(), e);
            }
        }
    }
1160167
def clean_built(outdir):
    """"""
    print("Removing the built files!")

    # Remove the  build folder
    build_dir = os.path.join(cwd, outdir)
    if os.path.exists(build_dir):
        shutil.rmtree(build_dir)
889396
public function clear()
    {
        $now = Carbon::now('UTC');

        ORM::for_table('files_downloads')
            ->where_lt('created_at', $now->subHours(SettingsFile::TOKENS_OLDER_THAN_HOURS))
            ->delete_many();
    }
572860
def clean_tmpdir(path):
    """"""
    if os.path.exists(path) and \
       os.path.isdir(path):
        rmtree(path)
1236743
def _cleanup(self):
        """"""
        for filename in os.listdir(self._storage_dir):
            file_path = path.join(self._storage_dir, filename)
            file_stat = os.stat(file_path)
            evaluate = max(file_stat.st_ctime, file_stat.st_mtime)
            if evaluate + self._duration < time.time():
                LOGGER.debug('Removing stale file: %s', file_path)
                os.unlink(file_path)
255555
def cleanup_full_hashes(self, keep_expired_for=(60 * 60 * 12)):
        """"""
        q = '''DELETE FROM full_hash WHERE expires_at < datetime(current_timestamp, '-{} SECONDS')
        '''
        log.info('Cleaning up full_hash entries expired more than {} seconds ago.'.format(keep_expired_for))
        with self.get_cursor() as dbc:
            dbc.execute(q.format(int(keep_expired_for)))
269496
def _clean_tmp_dirs(self):
        

        def onerror(fnc, path, excinfo):
            # we might not have rights to do this, the files could be owned by root
            self.logger.info("we were not able to remove temporary file %s: %s", path, excinfo[1])

        shutil.rmtree(self.tmpdir, onerror=onerror)
        self.tmpdir = None
        global _backend_tmpdir
        _backend_tmpdir = None
746432
def purge_old_event_logs(delete_before_days=7):
    
    delete_before_date = timezone.now() - timedelta(days=delete_before_days)
    logs_deleted = EventLog.objects.filter(
        created_on__lte=delete_before_date).delete()
    return logs_deleted
560805
def clear_stats
      clear_tcl = File.open("/var/tmp/clear-#{@buildtime}", 'w')
      clear_tcl.write clear_traffic_stats
      clear_tcl.close
      system "#{@ixia_exe} /var/tmp/clear-#{@buildtime}"
      File.delete clear_tcl
    end
294923
public function clear()
    {
        $now = Carbon::now('UTC');

        if ($handle = opendir(SettingsFile::TEMP_FOLDER)) {
            while (false !== ($file = readdir($handle))) {
                if ($file !== '.' && $file !== '..') {
                    $file_path = SettingsFile::TEMP_FOLDER . $file;
                    $file_time = filemtime($file_path);
                    $file_date = Carbon::createFromTimestamp($file_time, 'UTC');

                    if ($file_date->diffInDays($now) >= SettingsFile::OUTDATED_FILE_DAYS) {
                        @unlink($file_path);
                    }
                }
            }

            closedir($handle);
        }
    }
1116999
private static void deleteEveryIn(DirectoryStream<Path> caches) {
        for (Path notActualCache : caches) {
            LOGGER.debug("Deleting redundant cache dir {}", notActualCache);
            try {
                FileUtils.deleteDirectory(notActualCache.toFile());
            } catch (IOException e) {
                LOGGER.error("Can't delete cache dir <{}>", notActualCache, e);
            }
        }
    }
605986
def delete(self):
        '''
        

        '''
        versions = self.get_versions()
        self.api.manager.delete_archive_record(self.archive_name)

        for version in versions:
            if self.authority.fs.exists(self.get_version_path(version)):
                self.authority.fs.remove(self.get_version_path(version))

            if self.api.cache:
                if self.api.cache.fs.exists(self.get_version_path(version)):
                    self.api.cache.fs.remove(self.get_version_path(version))

        if self.authority.fs.exists(self.archive_name):
            self.authority.fs.removedir(self.archive_name)

        if self.api.cache:
            if self.api.cache.fs.exists(self.archive_name):
                self.api.cache.fs.removedir(self.archive_name)
1178418
function cleanDistDir(dir) {
  /* istanbul ignore else */
  if (dir !== process.cwd()) {
    fs.stat(dir, (err) => {
      if (!err) {
        del.sync([dir]);
      }

      fs.mkdirSync(dir);
    });
  }
}
194132
def purge_old_logs(delete_before_days=7):
    
    delete_before_date = timezone.now() - timedelta(days=delete_before_days)
    logs_deleted = Log.objects.filter(
        created_on__lte=delete_before_date).delete()
    return logs_deleted
352344
def remove(self, dist):
        """"""
        while dist.location in self.paths:
            self.paths.remove(dist.location)
            self.dirty = True
        Environment.remove(self, dist)
427627
def delete_cached_files(self, prefixes=[], suffixes=[]):
        
        for filename in listdir(self.cache_directory_path):
            delete = (
                any([filename.endswith(ext) for ext in suffixes]) or
                any([filename.startswith(pre) for pre in prefixes]))
            if delete:
                path = join(self.cache_directory_path, filename)
                logger.info("Deleting %s", path)
                remove(path)
986242
def delete_deps(self, conf, images):
        """"""
        for dependency_name, _ in conf.dependency_images():
            image = images[dependency_name]
            if image.deleteable_image:
                log.info("Removing un-needed image {0}".format(image.image_name))
                conf.harpoon.docker_api.remove_image(image.image_name)