Skip to content

Commit

Permalink
Fix delete old folders (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholasodonnell authored Sep 5, 2023
1 parent 9314208 commit 9f1d4e5
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
22 changes: 13 additions & 9 deletions apps/mirrarr/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,15 @@ export const mirrarr = async (args: MirrarrArgs) => {
logger.info('================= Staring =================')

try {
const { chmod, destination, pgid, puid, radarrApiKey, radarrUrl } = args
const {
chmod,
destination: destinationRaw,
pgid,
puid,
radarrApiKey,
radarrUrl,
} = args
const destination = destinationRaw.replace(/\/$/, '')

const radarr: Radarr = new Radarr({
apiKey: radarrApiKey,
Expand Down Expand Up @@ -74,10 +82,7 @@ export const mirrarr = async (args: MirrarrArgs) => {
for (const [mirroredFolder, moviePaths] of Object.entries(
mirroredFolderAndMoviePaths,
)) {
const destinationDir = `${destination.replace(
/\/$/,
'',
)}/${mirroredFolder}`
const destinationDir = `${destination}/${mirroredFolder}`

// create missing directory
if (createDirectoryIfNotExists(destinationDir, permissions)) {
Expand Down Expand Up @@ -111,10 +116,9 @@ export const mirrarr = async (args: MirrarrArgs) => {
}
}

// remove old folders
const removedDirs: string[] = removeFromDirNotInList(
destination,
destinationDirs,
// remove old lists & tags that no longer exists
const removedDirs: string[] = ['lists', 'tags'].flatMap((dir) =>
removeFromDirNotInList(`${destination}/${dir}`, destinationDirs),
)

for (const removedDir of removedDirs) {
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@arr-scripts/arr-scripts",
"version": "1.0.1",
"version": "1.0.2",
"author": "Nicholas O'Donnell <nicholas@nicholasodonnell.com>",
"license": "SEE LICENSE",
"private": true,
Expand Down

0 comments on commit 9f1d4e5

Please sign in to comment.