1. <?php
  2. /**
  3. * Teardown metadata processes (development only).
  4. *
  5. * This script is designed for development environments to clean up
  6. * any lingering metadata processes. It's intended for testing and
  7. * debugging purposes and should not be used in production.
  8. */
  9. // Define the paths to the metadata files/directories to remove.
  10. $metadata_files = [
  11. 'metadata_file_1.txt',
  12. 'metadata_file_2.csv',
  13. ];
  14. $metadata_directories = [
  15. 'metadata_dir_1',
  16. 'metadata_dir_2',
  17. ];
  18. // Function to remove a file.
  19. function removeFile(string $filePath): bool {
  20. if (file_exists($filePath)) {
  21. if (unlink($filePath)) {
  22. return true;
  23. }
  24. }
  25. return false;
  26. }
  27. // Function to remove a directory and its contents.
  28. function removeDirectory(string $dirPath): bool {
  29. if (is_dir($dirPath)) {
  30. if (rmdir($dirPath)) {
  31. return true;
  32. }
  33. }
  34. return false;
  35. }
  36. // Iterate through the metadata files.
  37. foreach ($metadata_files as $file) {
  38. echo "Removing file: $file\n";
  39. if (!removeFile($file)) {
  40. echo "Failed to remove file: $file\n";
  41. }
  42. }
  43. // Iterate through the metadata directories.
  44. foreach ($metadata_directories as $dir) {
  45. echo "Removing directory: $dir\n";
  46. if (!removeDirectory($dir)) {
  47. echo "Failed to remove directory: $dir\n";
  48. }
  49. }
  50. echo "Metadata teardown completed.\n";
  51. ?>

Add your comment