Skip to content

Commit

Permalink
Add message to schedule library scan tab
Browse files Browse the repository at this point in the history
  • Loading branch information
Oasis256 committed Jan 10, 2025
2 parents b0e0c2f + 7001adb commit 47006d9
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 21 deletions.
9 changes: 4 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,12 @@ RUN apk update && \
g++ \
tini \
unzip

COPY --from=build /client/dist /client/dist
COPY index.js package* /
COPY server server

ARG TARGETPLATFORM

ENV NUSQLITE3_DIR="/usr/local/lib/nusqlite3"
ENV NUSQLITE3_PATH="${NUSQLITE3_DIR}/libnusqlite3.so"

RUN case "$TARGETPLATFORM" in \
"linux/amd64") \
curl -L -o /tmp/library.zip "https://github.com/mikiher/nunicode-sqlite/releases/download/v1.2/libnusqlite3-linux-musl-x64.zip" ;; \
Expand All @@ -36,9 +32,12 @@ RUN case "$TARGETPLATFORM" in \
esac && \
unzip /tmp/library.zip -d $NUSQLITE3_DIR && \
rm /tmp/library.zip

RUN npm ci --only=production
RUN apk del make python3 g++
EXPOSE 80
ENV PORT=80
ENV CONFIG_PATH="/config"
ENV METADATA_PATH="/metadata"
ENV SOURCE="docker"
ENTRYPOINT ["tini", "--"]
CMD ["node", "index.js"]
3 changes: 3 additions & 0 deletions client/components/modals/libraries/ScheduleScan.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
<ui-checkbox v-model="enableAutoScan" @input="toggleEnableAutoScan" :label="$strings.LabelEnable" medium checkbox-bg="bg" label-class="pl-2 text-base md:text-lg" />
</div>
<widgets-cron-expression-builder ref="cronExpressionBuilder" v-if="enableAutoScan" v-model="cronExpression" @input="updatedCron" />
<div v-else>
<p class="text-yellow-400 text-base">{{ $strings.MessageScheduleLibraryScanNote }}</p>
</div>
</div>
</template>

Expand Down
1 change: 1 addition & 0 deletions client/strings/en-us.json
Original file line number Diff line number Diff line change
Expand Up @@ -839,6 +839,7 @@
"MessageResetChaptersConfirm": "Are you sure you want to reset chapters and undo the changes you made?",
"MessageRestoreBackupConfirm": "Are you sure you want to restore the backup created on",
"MessageRestoreBackupWarning": "Restoring a backup will overwrite the entire database located at /config and cover images in /metadata/items & /metadata/authors.<br /><br />Backups do not modify any files in your library folders. If you have enabled server settings to store cover art and metadata in your library folders then those are not backed up or overwritten.<br /><br />All clients using your server will be automatically refreshed.",
"MessageScheduleLibraryScanNote": "For most users, it is recommended to leave this feature disabled and keep the folder watcher setting enabled. The folder watcher will automatically detect changes in your library folders. The folder watcher doesn't work for every file system (like NFS) so scheduled library scans can be used instead.",
"MessageSearchResultsFor": "Search results for",
"MessageSelected": "{0} selected",
"MessageServerCouldNotBeReached": "Server could not be reached",
Expand Down
32 changes: 26 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
const optionDefinitions = [
{ name: 'config', alias: 'c', type: String },
{ name: 'metadata', alias: 'm', type: String },
{ name: 'port', alias: 'p', type: String },
{ name: 'host', alias: 'h', type: String },
{ name: 'source', alias: 's', type: String },
{ name: 'dev', alias: 'd', type: Boolean }
]

const commandLineArgs = require('./server/libs/commandLineArgs')
const options = commandLineArgs(optionDefinitions)

const Path = require('path')
process.env.NODE_ENV = options.dev ? 'development' : process.env.NODE_ENV || 'production'

const server = require('./server/Server')
global.appRoot = __dirname

Expand All @@ -17,14 +32,19 @@ if (isDev) {
process.env.ROUTER_BASE_PATH = devEnv.RouterBasePath || ''
}

const PORT = process.env.PORT || 80
const HOST = process.env.HOST
const CONFIG_PATH = process.env.CONFIG_PATH || '/config'
const METADATA_PATH = process.env.METADATA_PATH || '/metadata'
const SOURCE = process.env.SOURCE || 'docker'
const inputConfig = options.config ? Path.resolve(options.config) : null
const inputMetadata = options.metadata ? Path.resolve(options.metadata) : null

const PORT = options.port || process.env.PORT || 3333
const HOST = options.host || process.env.HOST
const CONFIG_PATH = inputConfig || process.env.CONFIG_PATH || Path.resolve('config')
const METADATA_PATH = inputMetadata || process.env.METADATA_PATH || Path.resolve('metadata')
const SOURCE = options.source || process.env.SOURCE || 'debian'

const ROUTER_BASE_PATH = process.env.ROUTER_BASE_PATH || ''

console.log('Config', CONFIG_PATH, METADATA_PATH)
console.log(`Running in ${process.env.NODE_ENV} mode.`)
console.log(`Options: CONFIG_PATH=${CONFIG_PATH}, METADATA_PATH=${METADATA_PATH}, PORT=${PORT}, HOST=${HOST}, SOURCE=${SOURCE}, ROUTER_BASE_PATH=${ROUTER_BASE_PATH}`)

const Server = new server(SOURCE, PORT, HOST, CONFIG_PATH, METADATA_PATH, ROUTER_BASE_PATH)
Server.start()
2 changes: 1 addition & 1 deletion package-lock.json

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

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
"description": "Self-hosted audiobook and podcast server",
"main": "index.js",
"scripts": {
"dev": "nodemon --watch server index.js",
"dev": "nodemon --watch server index.js -- --dev",
"start": "node index.js",
"client": "cd client && npm ci && npm run generate",
"prod": "npm run client && npm ci && node prod.js",
"prod": "npm run client && npm ci && node index.js",
"build-win": "npm run client && pkg -t node20-win-x64 -o ./dist/win/audiobookshelf -C GZip .",
"build-linux": "build/linuxpackager",
"docker": "docker buildx build --platform linux/amd64,linux/arm64 --push . -t advplyr/audiobookshelf",
Expand All @@ -18,15 +18,15 @@
"test": "mocha",
"coverage": "nyc mocha"
},
"bin": "prod.js",
"bin": "index.js",
"pkg": {
"assets": [
"client/dist/**/*",
"node_modules/sqlite3/lib/binding/**/*.node",
"server/migrations/*.js"
],
"scripts": [
"prod.js",
"index.js",
"server/**/*.js"
]
},
Expand Down
6 changes: 6 additions & 0 deletions server/Server.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ class Server {
}
}

if (process.env.PODCAST_DOWNLOAD_TIMEOUT) {
global.PodcastDownloadTimeout = process.env.PODCAST_DOWNLOAD_TIMEOUT
} else {
global.PodcastDownloadTimeout = 30000
}

if (!fs.pathExistsSync(global.ConfigPath)) {
fs.mkdirSync(global.ConfigPath)
}
Expand Down
10 changes: 8 additions & 2 deletions server/utils/comicBookExtractors.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,14 @@ class CbzStreamZipComicBookExtractor extends AbstractComicBookExtractor {
}

close() {
this.archive?.close()
Logger.debug(`[CbzStreamZipComicBookExtractor] Closed comic book "${this.comicPath}"`)
this.archive
?.close()
.then(() => {
Logger.debug(`[CbzStreamZipComicBookExtractor] Closed comic book "${this.comicPath}"`)
})
.catch((error) => {
Logger.error(`[CbzStreamZipComicBookExtractor] Failed to close comic book "${this.comicPath}"`, error)
})
}
}

Expand Down
2 changes: 1 addition & 1 deletion server/utils/ffmpegHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ module.exports.downloadPodcastEpisode = (podcastEpisodeDownload) => {
headers: {
'User-Agent': 'audiobookshelf (+https://audiobookshelf.org)'
},
timeout: 30000
timeout: global.PodcastDownloadTimeout
}).catch((error) => {
Logger.error(`[ffmpegHelpers] Failed to download podcast episode with url "${podcastEpisodeDownload.url}"`, error)
return null
Expand Down
4 changes: 3 additions & 1 deletion server/utils/parsers/parseComicMetadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ async function parse(ebookFile) {
archive = createComicBookExtractor(comicPath)
await archive.open()

const filePaths = await archive.getFilePaths()
const filePaths = await archive.getFilePaths().catch((error) => {
Logger.error(`[parseComicMetadata] Failed to get file paths from comic at "${comicPath}"`, error)
})

// Sort the file paths in a natural order to get the first image
filePaths.sort((a, b) => {
Expand Down
2 changes: 1 addition & 1 deletion server/utils/podcastUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ module.exports.getPodcastFeed = (feedUrl, excludeEpisodeMetadata = false) => {
return axios({
url: feedUrl,
method: 'GET',
timeout: 12000,
timeout: global.PodcastDownloadTimeout,
responseType: 'arraybuffer',
headers: {
Accept: 'application/rss+xml, application/xhtml+xml, application/xml, */*;q=0.8',
Expand Down

0 comments on commit 47006d9

Please sign in to comment.