A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/orgrim/pg_back/commit/a0c97c0c5e84e71e03c16be45da968e943d36b44 below:

make locking work on windows (#46) · orgrim/pg_back@a0c97c0 · GitHub

File tree Expand file treeCollapse file tree 3 files changed

+69

-0

lines changed

Filter options

Expand file treeCollapse file tree 3 files changed

+69

-0

lines changed Original file line number Diff line number Diff line change

@@ -3,6 +3,7 @@

3 3

## pg_back 2.0.1

4 4 5 5

* Use /var/run/postgresql as default host for connections

6 +

* Support Windows

6 7 7 8

## pg_back 2.0.0

8 9 Original file line number Diff line number Diff line change

@@ -23,6 +23,8 @@

23 23

// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF

24 24

// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

25 25 26 +

// +build !windows

27 + 26 28

package main

27 29 28 30

import (

Original file line number Diff line number Diff line change

@@ -0,0 +1,66 @@

1 +

// pg_back

2 +

//

3 +

// Copyright 2011-2021 Nicolas Thauvin and contributors. All rights reserved.

4 +

//

5 +

// Redistribution and use in source and binary forms, with or without

6 +

// modification, are permitted provided that the following conditions

7 +

// are met:

8 +

//

9 +

// 1. Redistributions of source code must retain the above copyright

10 +

// notice, this list of conditions and the following disclaimer.

11 +

// 2. Redistributions in binary form must reproduce the above copyright

12 +

// notice, this list of conditions and the following disclaimer in the

13 +

// documentation and/or other materials provided with the distribution.

14 +

//

15 +

// THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR

16 +

// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES

17 +

// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.

18 +

// IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,

19 +

// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES

20 +

// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;

21 +

// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND

22 +

// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT

23 +

// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF

24 +

// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

25 + 26 +

// +build windows

27 + 28 +

package main

29 + 30 +

import (

31 +

"fmt"

32 +

"os"

33 +

"path/filepath"

34 +

)

35 + 36 +

// lockPath on windows just creates a file without locking, it only tests if

37 +

// the file exist to consider it locked

38 +

func lockPath(path string) (*os.File, bool, error) {

39 +

if err := os.MkdirAll(filepath.Dir(path), 0755); err != nil {

40 +

return nil, false, err

41 +

}

42 + 43 +

info, err := os.Stat(path)

44 +

if err == nil {

45 +

if info.IsDir() {

46 +

return nil, false, &os.PathError{Op: "stat", Path: path, Err: fmt.Errorf("unexpected directory")}

47 +

}

48 +

return nil, false, err

49 +

}

50 + 51 +

l.Verboseln("creating lock file", path)

52 +

f, err := os.Create(path)

53 +

if err != nil {

54 +

return nil, false, err

55 +

}

56 +

return f, true, nil

57 +

}

58 + 59 +

// unlockPath releases the lock from the open file and removes the

60 +

// underlying path

61 +

func unlockPath(f *os.File) error {

62 +

path := f.Name()

63 +

l.Verboseln("removing lock file", path)

64 +

f.Close()

65 +

return os.Remove(path)

66 +

}

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4