Skip to content

Commit

Permalink
Prepare installer, Prevent infinite loop for sanitize_path_for_windows
Browse files Browse the repository at this point in the history
  • Loading branch information
henryruhs committed May 18, 2024
1 parent ee6e9b2 commit 176da11
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
8 changes: 4 additions & 4 deletions .install/facefusion.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

RequestExecutionLevel admin

Name 'FaceFusion NEXT'
OutFile 'FaceFusion_NEXT.exe'
Name 'FaceFusion 2.6.0'
OutFile 'FaceFusion_2.6.0.exe'

!define MUI_ICON 'facefusion.ico'

Expand Down Expand Up @@ -90,7 +90,7 @@ Section 'Download Your Copy'

DetailPrint 'Download Your Copy'
RMDir /r $INSTDIR
nsExec::Exec '$LOCALAPPDATA\Programs\Git\cmd\git.exe clone https://github.com/facefusion/facefusion --branch next .'
nsExec::Exec '$LOCALAPPDATA\Programs\Git\cmd\git.exe clone https://github.com/facefusion/facefusion --branch 2.6.0 .'
SectionEnd

Section 'Setup Your Environment'
Expand Down Expand Up @@ -160,7 +160,7 @@ Section 'Register The Application'
WriteUninstaller $INSTDIR\Uninstall.exe

WriteRegStr HKLM SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\FaceFusion DisplayName 'FaceFusion'
WriteRegStr HKLM SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\FaceFusion DisplayVersion 'NEXT'
WriteRegStr HKLM SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\FaceFusion DisplayVersion '2.6.0'
WriteRegStr HKLM SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\FaceFusion Publisher 'Henry Ruhs'
WriteRegStr HKLM SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\FaceFusion InstallLocation $INSTDIR
WriteRegStr HKLM SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\FaceFusion UninstallString $INSTDIR\uninstall.exe
Expand Down
4 changes: 3 additions & 1 deletion facefusion/filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def list_directory(directory_path : str) -> Optional[List[str]]:
return None


def sanitize_path_for_windows(full_path : str) -> str:
def sanitize_path_for_windows(full_path : str) -> Optional[str]:
buffer_size = 0

while True:
Expand All @@ -130,4 +130,6 @@ def sanitize_path_for_windows(full_path : str) -> str:

if buffer_size > buffer_threshold:
return unicode_buffer.value
if buffer_threshold == 0:
return None
buffer_size = buffer_threshold
5 changes: 4 additions & 1 deletion tests/test_filesystem.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import shutil
import pytest

from facefusion.common_helper import is_windows
Expand All @@ -13,6 +14,7 @@ def before_all() -> None:
'https://github.com/facefusion/facefusion-assets/releases/download/examples/source.mp3',
'https://github.com/facefusion/facefusion-assets/releases/download/examples/target-240p.mp4'
])
shutil.copyfile('.assets/examples/source.jpg', '.assets/examples/söurce.jpg')


def test_get_file_size() -> None:
Expand Down Expand Up @@ -84,4 +86,5 @@ def test_list_directory() -> None:

def test_sanitize_path_for_windows() -> None:
if is_windows():
assert sanitize_path_for_windows('.assets/examples/source.jpg').endswith('SOURCE~1.JPG')
assert sanitize_path_for_windows('.assets/examples/söurce.jpg') == 'ASSETS~1/examples/SURCE~1.JPG'
assert sanitize_path_for_windows('invalid') is None

0 comments on commit 176da11

Please sign in to comment.