Skip to content

Commit 4c49f1b

Browse files
committed
Make the previous portable mode as default
- change dir name to "ss_win_temp" to make things clear. - throw any exception caught when creating temp folder To workaround silly cleaning softwares and careless users. Signed-off-by: Syrone Wong <[email protected]>
1 parent b266bf4 commit 4c49f1b

File tree

3 files changed

+19
-49
lines changed

3 files changed

+19
-49
lines changed

README.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,6 @@ if you want to deactivate all, please clear all textboxes.
8989

9090
Please visit [Servers] for more information.
9191

92-
#### Portable Mode
93-
94-
If you want to put all temporary files into shadowsocks/temp folder instead of
95-
system temp folder, create a `shadowsocks_portable_mode.txt` into shadowsocks folder.
96-
9792
#### Develop
9893

9994
[Visual Studio 2015] & [.NET Framework 4.6.2 Developer Pack] are required.

shadowsocks-csharp/Controller/Service/PrivoxyRunner.cs

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -121,21 +121,13 @@ private static bool IsChildProcess(Process process)
121121
{
122122
try
123123
{
124-
if (Utils.IsPortableMode())
125-
{
126-
/*
127-
* Under PortableMode, we could identify it by the path of ss_privoxy.exe.
128-
*/
129-
var path = process.MainModule.FileName;
124+
/*
125+
* Under PortableMode, we could identify it by the path of ss_privoxy.exe.
126+
*/
127+
var path = process.MainModule.FileName;
130128

131-
return Utils.GetTempPath("ss_privoxy.exe").Equals(path);
132-
}
133-
else
134-
{
135-
var cmd = process.GetCommandLine();
129+
return Utils.GetTempPath("ss_privoxy.exe").Equals(path);
136130

137-
return cmd.Contains(_uniqueConfigFile);
138-
}
139131
}
140132
catch (Exception ex)
141133
{

shadowsocks-csharp/Util/Util.cs

Lines changed: 14 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -25,43 +25,26 @@ public BandwidthScaleInfo(float value, string unit_name, long unit)
2525

2626
public static class Utils
2727
{
28-
private static bool? _portableMode;
29-
private static string TempPath = null;
30-
31-
public static bool IsPortableMode()
32-
{
33-
if (!_portableMode.HasValue)
34-
{
35-
_portableMode = File.Exists(Path.Combine(Application.StartupPath, "shadowsocks_portable_mode.txt"));
36-
}
37-
38-
return _portableMode.Value;
39-
}
28+
private static string _tempPath = null;
4029

4130
// return path to store temporary files
4231
public static string GetTempPath()
4332
{
44-
if (TempPath == null)
33+
if (_tempPath == null)
4534
{
46-
if (IsPortableMode())
47-
try
48-
{
49-
Directory.CreateDirectory(Path.Combine(Application.StartupPath, "temp"));
50-
}
51-
catch (Exception e)
52-
{
53-
TempPath = Path.GetTempPath();
54-
Logging.LogUsefulException(e);
55-
}
56-
finally
57-
{
58-
// don't use "/", it will fail when we call explorer /select xxx/temp\xxx.log
59-
TempPath = Path.Combine(Application.StartupPath, "temp");
60-
}
61-
else
62-
TempPath = Path.GetTempPath();
35+
try
36+
{
37+
Directory.CreateDirectory(Path.Combine(Application.StartupPath, "ss_win_temp"));
38+
// don't use "/", it will fail when we call explorer /select xxx/ss_win_temp\xxx.log
39+
_tempPath = Path.Combine(Application.StartupPath, "ss_win_temp");
40+
}
41+
catch (Exception e)
42+
{
43+
Logging.Error(e);
44+
throw;
45+
}
6346
}
64-
return TempPath;
47+
return _tempPath;
6548
}
6649

6750
// return a full path with filename combined which pointed to the temporary directory

0 commit comments

Comments
 (0)