From 287e807a1d40c412eb48e7f720c35965a2acfb03 Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Thu, 8 Jul 2021 15:47:29 -0700 Subject: [PATCH] PBot: ensure data directory is not named `data` --- PBot/PBot.pm | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/PBot/PBot.pm b/PBot/PBot.pm index da2ebd55..b0a79617 100644 --- a/PBot/PBot.pm +++ b/PBot/PBot.pm @@ -61,12 +61,14 @@ use PBot::Users; use PBot::Utils::ParseDate; use PBot::WebPaste; +use Encode; +use File::Basename; + # set standard output streams to encode as utf8 binmode(STDOUT, ":utf8"); binmode(STDERR, ":utf8"); # decode command-line arguments from utf8 -use Encode; @ARGV = map { decode('UTF-8', $_, 1) } @ARGV; sub new { @@ -121,6 +123,12 @@ sub initialize { } } + # insist that data directory be copied + if (basename($conf{data_dir}) eq 'data') { + print STDERR "Data directory ($conf{data_dir}) cannot be named `data`. This is to ensure the directory is copied from its default location. Please follow doc/QuickStart.md.\n"; + exit; + } + # let modules register atexit subroutines $self->{atexit} = PBot::Registerable->new(pbot => $self, %conf);