private int CheckPrerequisitesForSmbBackup(string pstFileToSave)
        {
            FileInfo backupFile;
            FileInfo sourceFile = new FileInfo(pstFileToSave);
            int      fileId     = 0;

            if (_clientDb.IsPstFileRegistered(pstFileToSave))
            {
                // PST file is already known in the database
                fileId     = _clientDb.GetFileID(pstFileToSave);
                backupFile = new FileInfo(_clientDb.GetBackupFilePath(pstFileToSave).ToLower());
                if (String.Compare(backupFile.DirectoryName, FileSystem.ExpandDestinationFolder(AppSettings.FilesAndFoldersDestinationPath), true) != 0)
                {
                    // Destination have change
                    backupFile = new FileInfo(Path.Combine(FileSystem.ExpandDestinationFolder(AppSettings.FilesAndFoldersDestinationPath), backupFile.Name));
                    _clientDb.RenameBackupFile(pstFileToSave, backupFile.FullName);
                    _clientDb.DeleteHashes(fileId, 0);
                }
                if (backupFile.Name.EndsWith(".pst"))
                {
                    // Backup File is PST
                    _clientDb.RenameBackupFile(pstFileToSave, backupFile.FullName + ".partial");
                    if (backupFile.Exists)
                    {
                        // Backup.pst exists
                        File.Move(backupFile.FullName, backupFile.FullName + ".partial");
                    }
                    else
                    {
                        // Backup.pst does not exists
                        _clientDb.DeleteHashes(fileId, 0);
                    }
                }
                else
                {
                    // Backup File is Partial
                    if (!backupFile.Exists)
                    {
                        // BackupFile.pst.partial does not exists
                        _clientDb.DeleteHashes(fileId, 0);
                    }
                }
            }
            else
            {
                // PST file is not in the database
                fileId     = _clientDb.GetAvailableFileId();
                backupFile = new FileInfo(Path.Combine(FileSystem.ExpandDestinationFolder(AppSettings.FilesAndFoldersDestinationPath), sourceFile.Name + ".partial"));
                _clientDb.RegisterNewPstFile(fileId, pstFileToSave, backupFile.FullName);

                if (backupFile.Exists)
                {
                    // backup.pst.partial already exists
                    backupFile.Delete();
                }
            }

            // Create or Resize
            backupFile = new FileInfo(Path.Combine(FileSystem.ExpandDestinationFolder(AppSettings.FilesAndFoldersDestinationPath), sourceFile.Name + ".partial"));
            if (FileSystem.ResizeFile(backupFile.FullName, sourceFile.Length) == -1)
            {
                // backup file have been shrinked, shrink Hashes table
                _clientDb.ShrinkChunkList(fileId, sourceFile.Length, _chunkSize);
            }
            return(fileId);
        }