Could not move file failes without error - Multiple nzbget instances
Hi, i am using
Currently installed: 21.1
You are running the most current version.
on an Vero 4k+ with OSMC
Linux osmc 3.14.29-160-osmc #1 SMP Sun Sep 13 13:55:21 UTC 2020 aarch64 GNU/Linux
Sometimes i get this error message for postprocessing:
Sat Jul 24 10:39:03 2021 1627115943 INFO Unrar: All OK
Sat Jul 24 10:39:03 2021 1627115943 ERROR Could not move file /media/ssd_rootfs/nzbget/Filme/Nobody.2021.German.DL.1080p.BluRay.x264-DETAiLS/_unpack/Nobody.2021.German.DL.1080p.BluRay.x264-DETAiLS to /media/ssd_rootfs/nzbget/Filme/Nobody.2021.German.DL.1080p.BluRay.x264-DETAiLS/Nobody.2021.German.DL.1080p.BluRay.x264-DETAiLS:
Sat Jul 24 10:39:03 2021 1627115943 ERROR Unpack for Nobody.2021.German.DL.1080p.BluRay.x264-DETAiLS failed
But the file itself is moved to the target directory:
osmc@osmc:/media/ssd_rootfs/nzbget/Filme/Nobody.2021.German.DL.1080p.BluRay.x264-DETAiLS$ tree -ah
.
├── [4.0K] Nobody.2021.German.DL.1080p.BluRay.x264-DETAiLS
│ ├── [ 10G] nobody.2021.german.dl.1080p.bluray.x264-details.mkv
│ ├── [6.4K] nobody.2021.german.dl.1080p.bluray.x264-details.nfo
│ └── [4.0K] Sample
│ └── [ 67M] nobody.2021.german.dl.1080p.bluray.x264-details.sample.mkv
└── [4.0K] _unpack
└── [4.0K] Nobody.2021.German.DL.1080p.BluRay.x264-DETAiLS
├── [ 10G] nobody.2021.german.dl.1080p.bluray.x264-details.mkv
├── [6.4K] nobody.2021.german.dl.1080p.bluray.x264-details.nfo
└── [4.0K] Sample
└── [ 67M] nobody.2021.german.dl.1080p.bluray.x264-details.sample.mkv
5 directories, 6 files
So somehow in Unpack.cpp
if (!FileSystem::MoveFile(srcFile, dstFile) && !hiddenFile)
{
PrintMessage(Message::mkError, "Could not move file %s to %s: %s", *srcFile, *dstFile,
*FileSystem::GetLastErrorMessage());
ok = false;
}
failes without any LastError Message. I have no clue what could be the cause of it. Maybe it would be better to print the return of MoveFile to get some hints?
Going forward to FileSystem.cpp leads to:
bool FileSystem::MoveFile(const char* srcFilename, const char* dstFilename)
{
#ifdef WIN32
return _wrename(UtfPathToWidePath(srcFilename), UtfPathToWidePath(dstFilename)) == 0;
#else
bool ok = rename(srcFilename, dstFilename) == 0;
if (!ok && errno == EXDEV)
{
ok = CopyFile(srcFilename, dstFilename) && DeleteFile(srcFilename);
}
return ok;
#endif
}
Since the files were copied there could be something with DeleteFile
bool FileSystem::DeleteFile(const char* filename)
{
#ifdef WIN32
return _wremove(UtfPathToWidePath(filename)) == 0;
#else
return remove(filename) == 0;
#endif
}
But there is no error message. So CopyFile could have copied the files but just finished with an error:
bool FileSystem::CopyFile(const char* srcFilename, const char* dstFilename)
{
DiskFile infile;
if (!infile.Open(srcFilename, DiskFile::omRead))
{
return false;
}
DiskFile outfile;
if (!outfile.Open(dstFilename, DiskFile::omWrite))
{
return false;
}
CharBuffer buffer(1024 * 50);
int cnt = buffer.Size();
while (cnt == buffer.Size())
{
cnt = (int)infile.Read(buffer, buffer.Size());
outfile.Write(buffer, cnt);
}
infile.Close();
outfile.Close();
return true;
}
Since the files were copied this had to work. But since this function is the only one that will not set errno there should be a problem here. Maybe some other process moved the files already?
So you know sometimes you have to write it down to get it (or tell someone else).
I was too lazy to setup a servicefile for nzbget so i set
/home/osmc/nzbget/nzbget/nzbget -D
in my .bashrc.
So everytime i login over ssh another instance of nzbget was running. And some instance was faster with moving the file... But there was only one unpack operation. I fixed it now with a service.
Maybe it shouln'd be possible to start multiple nzbget instances on the same port?
Is the option LockFile set? It should have prevented the running of multiple instances?
It is/was: /var/run/nzbget.pid osmc@osmc:~$ lslocks COMMAND PID TYPE SIZE MODE M START END PATH nzbget 407 POSIX 4B WRITE 0 0 0 /run/nzbget.pid But at the moment i cannot reproduce this :( I cannot get multiple instances of nzbget running