The 5th annual nopCommerce conference will take place in India on the 10th-11th of October. Please find more about this event here

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

Posted: May 29, 2019 at 6:02 PM Quote #235782
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 поменять или в верхнем методе добавить проверку на папку.
This post/answer is useful
1
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
Posted: June 03, 2019 at 5:37 AM Quote #237072
Done. Please see this commit for more details

Russian

Спасибо foxnetsoft за помощь, мы не стали менять метод Combine, так как сложно тестировать его совместимость с UNIX системой и еще рядом особенностей разных платформ. Я нашел способ исправить ошибку в том месте где она возникает, предложенное решение должно работать стабильно на всех платформах.
This post/answer is useful
2
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
Interested in the dedicated Premium support services provided by core developers? Please visit http://www.nopcommerce.com/supportservices.aspx

Regards,
Sergey Koshelev
Premium support services
  • Dedicated premium support services provided by core developers are intended for persons who run mission critical websites, work on projects with tight deadlines, or want to get dedicated support.
Professional services
  • Want to open a new store? Want to take your store to the next level? Need a custom extension? We can customize nopCommerce to fit your store perfectly. Request a quote to get started.
eCommerce CONFERENCE 2019
Learn more