mirror of
https://github.com/owncast/owncast.git
synced 2024-11-21 20:28:15 +03:00
Make the public dir live inside data to make volume mounting easier
This commit is contained in:
parent
e984f14089
commit
44fe52fc5a
3 changed files with 19 additions and 17 deletions
|
@ -27,4 +27,7 @@ var (
|
||||||
|
|
||||||
// CustomEmojiPath is the emoji directory.
|
// CustomEmojiPath is the emoji directory.
|
||||||
CustomEmojiPath = filepath.Join(DataDirectory, "emoji")
|
CustomEmojiPath = filepath.Join(DataDirectory, "emoji")
|
||||||
|
|
||||||
|
// PublicFilesPath is the optional directory for hosting public files.
|
||||||
|
PublicFilesPath = filepath.Join(DataDirectory, "public")
|
||||||
)
|
)
|
||||||
|
|
|
@ -386,7 +386,7 @@ func Start() error {
|
||||||
})
|
})
|
||||||
|
|
||||||
// Optional public static files
|
// Optional public static files
|
||||||
http.Handle("/public/", http.StripPrefix("/public/", http.FileServer(http.Dir("./public"))))
|
http.Handle("/public/", http.StripPrefix("/public/", http.FileServer(http.Dir(config.PublicFilesPath))))
|
||||||
|
|
||||||
port := config.WebServerPort
|
port := config.WebServerPort
|
||||||
ip := config.WebServerIP
|
ip := config.WebServerIP
|
||||||
|
|
|
@ -4,7 +4,7 @@ const fs = require('fs');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const randomString = require('./lib/rand').randomString;
|
const randomString = require('./lib/rand').randomString;
|
||||||
|
|
||||||
const publicPath = path.resolve(__dirname, '../../../public');
|
const publicPath = path.resolve(__dirname, '../../../data/public');
|
||||||
const filename = randomString() + '.txt';
|
const filename = randomString() + '.txt';
|
||||||
const fileContent = randomString();
|
const fileContent = randomString();
|
||||||
|
|
||||||
|
@ -15,12 +15,12 @@ test('random public static file does not exist', async (done) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('public directory is writable', async (done) => {
|
test('public directory is writable', async (done) => {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
writeFileToPublic();
|
writeFileToPublic();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
if (err.code === "ENOENT") { // path does not exist
|
if (err.code === 'ENOENT') {
|
||||||
|
// path does not exist
|
||||||
fs.mkdirSync(publicPath);
|
fs.mkdirSync(publicPath);
|
||||||
writeFileToPublic();
|
writeFileToPublic();
|
||||||
} else {
|
} else {
|
||||||
|
@ -33,25 +33,24 @@ test('public directory is writable', async (done) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('public static file is accessible', async (done) => {
|
test('public static file is accessible', async (done) => {
|
||||||
|
request
|
||||||
request.get('/public/' + filename).expect(200).then((res) => {
|
.get('/public/' + filename)
|
||||||
expect(res.text).toEqual(fileContent);
|
.expect(200)
|
||||||
done();
|
.then((res) => {
|
||||||
});
|
expect(res.text).toEqual(fileContent);
|
||||||
|
done();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test('public static file is persistent and not locked', async (done) => {
|
test('public static file is persistent and not locked', async (done) => {
|
||||||
|
|
||||||
fs.unlink(path.join(publicPath, filename), (err) => {
|
fs.unlink(path.join(publicPath, filename), (err) => {
|
||||||
if (err) { throw err; }
|
if (err) {
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
function writeFileToPublic() {
|
function writeFileToPublic() {
|
||||||
fs.writeFileSync(
|
fs.writeFileSync(path.join(publicPath, filename), fileContent);
|
||||||
path.join(publicPath, filename),
|
}
|
||||||
fileContent
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue