Can't upload ZIP file with plugin and subfolders in nop 4.20

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
4 years ago
Can't upload ZIP file with plugin and subfolders in nop 4.20.

Try to upload this ZIP file
http://foxnetsoft.com/content/files/foxnetsoft.stripedirect.zip

Plugin in this ZIP file has subfolder Resources

ZIP has entry '4.20/FoxNetSoft.StripeDirect/Resources/'
Pay attention to "/" at the end of the file.

Nopcommerce creates empty file Resources instead of creating folder Resources

This line of code has error.
var filePath = _fileProvider.Combine(pathToUpload, fileName.Replace("/", "\\"));


Russian

В архиве с плагином есть подпапка Resources
Ошибка в методе
_fileProvider.Combine


Раньше когда мы передавали параметры со слешами в конце то получали строку со слешами в конце
Пример, как было
_fileProvider.Combine("d:\\nop420", "Resources\\");
Получаем
"d:\nop420\Resources\"

А теперь получаем
"d:\nop420\Resources"

без слеша в конце!
Причина в том что новый метод обезает конечный слеш

public virtual string Combine(params string[] paths)
        {
            var path = Path.Combine(paths.SelectMany(p => IsUncPath(p) ? new[] { p } : p.Split('\\', '/')).ToArray());

            if (Environment.OSVersion.Platform == PlatformID.Unix && !IsUncPath(path))
                //add leading slash to correctly form path in the UNIX system
                path = "/" + path;

            return path;
        }


Нужно или Combine поменять или в верхнем методе добавить проверку на папку.
4 years ago
Done. Please see this commit for more details

Russian

Спасибо foxnetsoft за помощь, мы не стали менять метод Combine, так как сложно тестировать его совместимость с UNIX системой и еще рядом особенностей разных платформ. Я нашел способ исправить ошибку в том месте где она возникает, предложенное решение должно работать стабильно на всех платформах.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.